home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tchk050.arc / TCHK.DOC < prev    next >
Text File  |  1988-11-19  |  124KB  |  5,241 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                        TCHK - a Turbo C library
  16.  
  17.                              Version 0.50
  18.  
  19.                         Documentation for TCHK
  20.  
  21.                                   by
  22.  
  23.                            Howard Kapustein
  24.  
  25.  
  26.  
  27.  
  28.  
  29.                            Howard Kapustein
  30.  
  31.                            1695 Barbara Lane
  32.  
  33.                          East Meadow, NY 11554
  34.  
  35.                             (516) 481-9612
  36.  
  37.  
  38.  
  39.                 (c) Copyright 1987, All rights reserved
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.                                                                     -1-
  55.  
  56.                                     Contents
  57.     
  58.     
  59.     COPYRIGHT AND DISCLAIMER  ..........................................   3
  60.     
  61.     TRADEMARKS  ........................................................   3
  62.     
  63.     LICENSE  ...........................................................   3
  64.     
  65.     BACKGROUND  ........................................................   3
  66.     
  67.     FILES  .............................................................   4
  68.     
  69.     IN THE BEGINNING..  ................................................   4
  70.     
  71.     FEATURES  ..........................................................   5
  72.     
  73.     FUNCTIONS  .........................................................   5
  74.          atrim - trims leading and trailing blanks  ....................   7
  75.          ltrim - trims leading blanks  .................................   7
  76.          rtrim - trims trailing blanks  ................................   7
  77.          box - draw a box  .............................................   8
  78.          clear - clears a portion of the screen  .......................   9
  79.          clear_typeahead - clear typeahead buffer  .....................  10
  80.          cls - clear screen  ...........................................  11
  81.          cursor_flip - toggle the cursor type  .........................  12
  82.          cursor_off - turn the cursor off  .............................  13
  83.          cursor_on - turn the cursor on  ...............................  14
  84.          dayofyear - calculate the day of the year  ....................  15
  85.          daysleft - calculate the days left in the year  ...............  16
  86.          ddatetolong - convert a date to long string  ..................  17
  87.          ddatetoshort - convert a date to long string  .................  18
  88.          ddatetostr - convert a date to abbrev. string  ................  19
  89.          delay - wait for a time delay  ................................  20
  90.          diffddate - calculate the difference in 2 dates  ..............  21
  91.          getc_match - get specific input,  case independent  ...........  22
  92.          getk_match - get specific input, case dependent  ..............  22
  93.          getddate - inputs a date from the keyboard  ...................  23
  94.          getdouble - inputs a double from the keyboard  ................  24
  95.          getfname - get a filename from the keyboard  ..................  25
  96.          getget - get a string from the keyboard w/editing  ............  26
  97.          getint - inputs an integer from the keyboard  .................  27
  98.          getk - get a key  .............................................  28
  99.          getlogical - get Yes/No  ......................................  29
  100.          getreal - inputs a real from the keyboard  ....................  30
  101.          getstr - input a string from the keyboard  ....................  31
  102.          getyn - get Yes/No  ...........................................  32
  103.          gotoxy - move cursor to coordinates (x,y)  ....................  33
  104.          horiz_line - draw a horizontal line  ..........................  34
  105.          inkey - get a key  ............................................  35
  106.          intlen - calculate length of integer in a string  .............  36
  107.          isCGA - is Color Graphics adapter installed  ..................  37
  108.          isEGA - is Enhanced Graphics adapter installed  ...............  37
  109.          isHerc - is Hercules Graphics adapter installed  ..............  37
  110.          isMDA - is Monochrome adapter installed  ......................  37
  111.          isEMSavail - is EMS available  ................................  38
  112.          isleapyear - is a year a leap year  ...........................  39
  113.          leftstr - return the left portion of string  ..................  40
  114.          midstr - return a piece of a string  ..........................  40
  115.          rightstr - return the right portion of a string  ..............  40
  116.     
  117.  
  118.  
  119.  
  120.                                                                     -2-
  121.  
  122.          lotus_setup - creates info for menu_lotus()  ..................  41
  123.          menu_lotus - Lotus style menu  ................................  42
  124.          monthexpand - convert a month abbrev to its name  .............  44
  125.          putk - put a character w/attribute on the screen  .............  45
  126.          putsay - put a string with attribute on the screen  ...........  46
  127.          putstr - put a string with attribute on the screen  ...........  47
  128.          read_cursor - reads cursor information  .......................  48
  129.          read_mode - find screen width, mode and page  .................  49
  130.          restore_box - restore a part of the screen  ...................  50
  131.          restore_screen - restore screen  ..............................  51
  132.          ROM_date - gets the ROM id date  ..............................  52
  133.          ROM_id - gets the ROM id byte  ................................  53
  134.          save_box - save a part of the screen  .........................  54
  135.          save_screen - save screen  ....................................  55
  136.          scroll_down - scroll window down  .............................  56
  137.          scroll_up - scroll window up  .................................  57
  138.          set_color - set the default attribute (color)  ................  58
  139.          set_cursor - sets cursor scan lines  ..........................  59
  140.          set_mode - set the video mode  ................................  60
  141.          strcomma - convert a string to xx,xxx,xxx format  .............  61
  142.          strdel - delete part of a string  .............................  62
  143.          strins - insert one string into another  ......................  63
  144.          strrep - replicate a char  ....................................  64
  145.          strshleft - shift string left  ................................  65
  146.          strshright - shift string right  ..............................  65
  147.          strtoddate - convert a date string to a structure  ............  66
  148.          strtodol - converts a string to dollar format  ................  67
  149.          strtotime - convert a string to a time structure  .............  68
  150.          timetostr - convert time structure to a string  ...............  69
  151.          valid_date - check if a date is valid  ........................  70
  152.          vert_line - draw a vertical line  .............................  71
  153.          wherex - X-coordinate of cursor   .............................  72
  154.          wherey - y-coordinate of cursor   .............................  73
  155.     
  156.     #DEFINES  ..........................................................  74
  157.          Datehk.h  .....................................................  74
  158.          Howard.h  .....................................................  74
  159.          Ibm.h  ........................................................  74
  160.          Math.h  .......................................................  75
  161.          Video.h  ......................................................  75
  162.     
  163.     VARIABLE TYPES  ....................................................  75
  164.     
  165.     GLOBAL VARIABLES  ..................................................  76
  166.          Keyboard variables:  ..........................................  76
  167.          Video variables:  .............................................  76
  168.     
  169.     FUTURE REVISIONS  ..................................................  76
  170.     
  171.     INDEX  .............................................................  78
  172.     
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.                                                                    -3-
  187.  
  188.     
  189.     
  190.                             COPYRIGHT AND DISCLAIMER
  191.     
  192.           This library and documentation are Copyrighted (C) 1987 by Howard
  193.           Kapustein, All Rights Reserved.
  194.     
  195.           Use of this library acknowledges this disclaimer of warranty:
  196.           "This library is supplied as-is. The author disclaims all
  197.           warranties, expressed or implied, including, without limitation,
  198.           the warranties of merchantability and of fitness of this library
  199.           for any purpose. The author assumes no liability for damages
  200.           direct or consequential, which may result from the use of this
  201.           library."
  202.     
  203.     
  204.     
  205.                                    TRADEMARKS
  206.     
  207.           Macintosh is a registered trademark of Apple Incorporated.
  208.        dBase III+ is a registered trademark of Ashton-Tate Incorporated.
  209.           Turbo C is a registered trademark of Borland International.
  210.                Symphony is a registered trademark of Lotus Corp.
  211.     
  212.     
  213.     
  214.                                     LICENSE
  215.     
  216.           TCHK is distributed as "shareware". Nonregistered users are
  217.           granted a limited license to use this library for personal,
  218.           private ends, and may develop software using the functions
  219.           contained herein, but may not distribute, sell nor otherwise
  220.           release or profit from any product made with TCHK. Users may
  221.           become REGISTERED owners for a small pittance of $15. Registering
  222.           has the following benefits:
  223.     
  224.                Registered owners will receive TCHK compiled for use with
  225.                all memory models (not just the small memory model
  226.                distributed here.)
  227.     
  228.                Registered owners are entitled to utilize TCHK in commercial
  229.                applications.
  230.     
  231.                Registered owners will automatically be registered for all
  232.                releases up to and including 1.00 (I may extend this, but
  233.                for now you get all releases up to 1.00.)
  234.     
  235.           REGISTERED owners may purchase the source code for TCHK for $25.
  236.     
  237.     
  238.     
  239.                                    BACKGROUND
  240.     
  241.           I am a student at Rensselaer Polytechnic Institute majoring in
  242.           computer science. I also do consulting/programming work as a
  243.           sideline (hint hint.) When I purchased Turbo C, I wanted to do
  244.           more than bare bones printf(). I was also engaged in designing
  245.           some software requiring the use of dates, and some other unusual
  246.           functions. Thus, after several months of testing and use, I
  247.           developed a rather useful collection of functions. After some 
  248.  
  249.  
  250.  
  251.  
  252.                                                                    -4-
  253.  
  254.           requests from other programmers, I decided to bundle most of them
  255.           together and <gasp> document them. This library is a collection
  256.           of most of these functions.
  257.     
  258.     
  259.     
  260.                                      FILES
  261.     
  262.           You may not distribute TCHK except in unmodified form, and it
  263.           must be distributed with all the following files:
  264.     
  265.                TCHKS.LIB      - small memory model library
  266.                TCHK.DOC       - documentation for TCHK
  267.                TCHKDEMO.C     - demo program of some functions
  268.                TCHKDEMO.PRJ   - project used to compile TCHKDEMO.C
  269.                TCHK.TC        - Turbo C configuration file
  270.     
  271.                COLOR.H        - color definitions
  272.                DATEHK.H       - header file for date routines
  273.                FILEHK.H       - header file for file routines
  274.                HOWARD.H       - miscellaneous definitions
  275.                IBM.H          - header file for misc. IBM routines
  276.                KEYBOARD.H     - header file for keyboard routines
  277.                KEYCODE.H      - keyboard scan codes
  278.                MATHHK.H       - header file of math defines
  279.                MENUHK.H       - header file for menu routines
  280.                STRINGHK.H     - header file for string routines
  281.                TIMEHK.H       - header file for time routines
  282.                VIDEO.H        - header file for video routines
  283.     
  284.           To compile the demo program TCHKDEMO.C, load the configuration
  285.           file TCHK.TC and the project file TCHKDEMO.PRJ and compile
  286.           TCHK.C. Make sure you check the Turbo C directories before
  287.           compiling.
  288.     
  289.     
  290.     
  291.                               IN THE BEGINNING...
  292.     
  293.           Except where explicitly stated, all of these functions have been
  294.           tested and compiled on my system:
  295.     
  296.                - IBM PC
  297.                - 640K memory
  298.                - (CGA) Color Graphics Adapter
  299.                - DOS 3.2
  300.     
  301.           TCHK was compiled from the interactive environment of Turbo C,
  302.           with the following options changed from the default:
  303.     
  304.           For more info, check out the configuration file TCHK.TC.
  305.     
  306.           This library was written in 100% Turbo C, with no use of inline
  307.           Assembly, compiled with Turbo C 1.0 and created with PLIB86.
  308.     
  309.     
  310.     
  311.     
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.                                                                    -5-
  320.  
  321.                                     FEATURES
  322.     
  323.           TCHK sports many useful features not found in other shareware
  324.           packages. Aside from many input and output routines, TCHK is the
  325.           only package I have seen (and I've looked) that supplies date and
  326.           time functions. Also unique to TCHK is the Lotus style slash-bar
  327.           menu function.
  328.     
  329.           Many of the functions requiring output as a side effect (most
  330.           noticeably the keyboard functions) make use of some of the output
  331.           routines prototyped in VIDEO.H. If you use almost any of the
  332.           keyboard routines, expect both the keyboard and the video
  333.           routines to be linked into your program. This is true of some of
  334.           the other routines as well (the lotus menus require the menu,
  335.           keyboard, video and time routines.) Since the entire .LIB file is
  336.           rather small, there is no harm done. Perhaps a future version
  337.           will have the routines segmented more (if you really want to
  338.           break up the library, you can always purchase the source code...)
  339.     
  340.     
  341.     
  342.                                    FUNCTIONS
  343.     
  344.           Most of the functions are documented well enough below, although
  345.           I feel a few more explanations are necessary:
  346.     
  347.                In the interactive environment you can #define one item in
  348.                terms of another, including spaces. If anyone knows how to
  349.                do this with the command line version, please let me know.
  350.                The variable type  byte  is just an unsigned char. If you
  351.                use the command line version of TC you will have to change
  352.                the header files of TCHK.
  353.     
  354.                All functions asking for screen coordinates treat the top
  355.                left corner as row zero, column zero (0,0).
  356.     
  357.                Most functions rely on interrupts and low memory addresses
  358.                (400:xxxx) to comply  with the IBM standard. Certain values
  359.                (for instance, the current video page) can be found by an
  360.                interrupt or by peeking at the value stored in low memory.
  361.                Many of the video functions especially require these values
  362.                to be found at the proper places. If your clone is radically
  363.                different from the IBM standard some of these functions may
  364.                not work properly. I didn't want to have to write a million
  365.                small functions that are just background support for the
  366.                functions found here (like current page number, etc.) so I
  367.                used the #defines found in the headers (see video.h for more
  368.                details.)
  369.     
  370.                TCHK has not been tested on a Hercules or MDA video card
  371.                since I do not have access to either piece of hardware,
  372.                although the methods are well documented and should cause no
  373.                problems.
  374.     
  375.                All direct screen accesses have built-in snow control. On
  376.                CGA monitors, the snow was horrendous without it. Unless I
  377.                code these routines in assembler, I won't be able to squeeze
  378.                any more optimization out of these routines. I do plan on
  379.                converting these functions to assembler, but I just don't
  380.                have the time right now.
  381.     
  382.  
  383.  
  384.  
  385.                                                                    -6-
  386.  
  387.     
  388.           One type of command you will NOT find in TCHK are windowing
  389.           commands. There are plenty of windowing libraries available. You
  390.           should not try to make your poor IBM into a Mac, it won't cut it.
  391.           Splurge for the Mac, you'll be happier. Yes, I know, the
  392.           'windowing' interface is nicer. I use 'windows' too, although
  393.           mine are just boxes. I find it more than suitable for my current
  394.           needs.
  395.     
  396.           The functions are listed in the same manner as the Turbo C
  397.           manual, in alphabetical order.
  398.     
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.                                                                    -7-
  452.  
  453.     
  454.     Name                  atrim - trims leading and trailing blanks
  455.                           ltrim - trims leading blanks
  456.                           rtrim - trims trailing blanks
  457.     
  458.     Usage                char *atrim(char *source);
  459.                          char *ltrim(char *source);
  460.                          char *rtrim(char *source);
  461.     
  462.     Prototype in         stringhk.h
  463.     
  464.     Description          these functions remove leading and/or trailing
  465.                          blanks in a string.
  466.     
  467.     Return value         returns a pointer to the storage location
  468.                          containing the trimmed string, or NULL if space
  469.                          could not be allocated. The returned string is NOT
  470.                          the same as the string passed to the function.
  471.                          This function does NOT write over the string
  472.                          passed to it.
  473.     
  474.     
  475.     Example              #include <stringhk.h>
  476.                          #include <stdio.h>           /* for the printf */
  477.     
  478.                          main()
  479.                          {
  480.                               char msg[25], *trimmed
  481.     
  482.                               strcpy(msg,"  Hello everyone   ");
  483.                               trimmed = ltrim(msg);
  484.                               printf("String [%s]\n",msg);
  485.                               printf("ltrim  [%s]\n",trimmed);
  486.                               free(trimmed);
  487.                               trimmed = rtrim(msg);
  488.                               printf("rtrim  [%s]\n",trimmmed);
  489.                               free(trimmed);
  490.                               trimmed = atrim(msg);
  491.                               printf("atrim  [%s]\n",trimmmed);
  492.                          }
  493.          
  494.     Program output       String [  Hello everyone   ]
  495.                          ltrim  [Hello everyone   ]
  496.                          rtrim  [  Hello everyone]
  497.                          atrim  [Hello everyone]
  498.     
  499.     
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.                                                                    -8-
  518.  
  519.     
  520.     Name                  box - draw a box
  521.     
  522.     Usage                int box(int top, int left, int bottom, int right,
  523.                               byte frame[]);
  524.     
  525.     
  526.     Prototype in         video.h
  527.     
  528.     Description          draws a box via INTerrupts.
  529.                          frame must be have at leeast 9 elements (byte
  530.                          frame[9]). The box characters are frame[0] (top
  531.                          left) to frame[7] (left wall), going clockwise. If
  532.                          frame[8] != '\0' the box is filled with it.
  533.     
  534.     Return value         returns zero upon succesful completion, -1 if
  535.                          invalid coordinates are given.
  536.     
  537.     See also             global variables
  538.                          horiz_line(), restore_box(), restore_screen(),
  539.                          save_box(), save_screen(), vert_line()
  540.     
  541.     Example              #include <video.h>
  542.     
  543.                          main()
  544.                          {
  545.                               byte framebox[9];
  546.     
  547.                               strcpy(framebox,"abcdefghi");
  548.                               box(1,4,4,10,framebox);
  549.                          }
  550.     
  551.     Program output       abbbbbc
  552.                          hiiiiid
  553.                          hiiiiid
  554.                          gfffffe
  555.     
  556.     
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.                                                                    -9-
  584.  
  585.     
  586.     Name                  clear - clears a portion of the screen
  587.     
  588.     Usage                void clear(int top, int left, int bottom, int
  589.                          right);
  590.     
  591.     Prototype in         video.h
  592.     
  593.     Description          clears a box of the screen with INT 0x10, Service
  594.                          6.
  595.     
  596.     Return value         nothing.
  597.     
  598.     See also             cls()
  599.     
  600.     Example              #include <video.h>
  601.     
  602.                          main()
  603.                          {
  604.                               clear(0,0,3,79);  /* clear top 4 lines of
  605.                               screen */
  606.                          }
  607.     
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.                                                                    -10-
  650.  
  651.     
  652.     Name                  clear_typeahead - clear typeahead buffer
  653.     
  654.     Usage                int clear_typeahead(void);
  655.     
  656.     Prototype in         keyboard.h
  657.     
  658.     Description          clears the typeahead buffer and returns the number
  659.                          of keystrokes cleared
  660.     
  661.     Return value         number of keystrokes emptied from the typeahead
  662.                          buffer
  663.     
  664.     Example              #include <keyboard.h>
  665.                          #include <stdio.h>
  666.     
  667.                          main()
  668.                          {
  669.                               printf("# keystrokes emptied = %d",
  670.                                         clear_typeahead());
  671.                          }
  672.     
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.                                                                    -11-
  716.  
  717.     
  718.     Name                  cls - clear screen
  719.     
  720.     Usage                void cls(void);
  721.     
  722.     Prototype in         video.h
  723.     
  724.     Description          clears screen by INT 0x10, Service 6 (scroll
  725.                          window up) and resets cursor to (0,0).
  726.     
  727.     Return value         nothing.
  728.     
  729.     See also             clear()
  730.     
  731.     Example              #include <video.h>
  732.     
  733.                          main()
  734.                          {
  735.                               cls()
  736.                          }
  737.     
  738.     
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.                                                                    -12-
  782.  
  783.     
  784.     Name                  cursor_flip - toggle the cursor type
  785.     
  786.     Usage                void cursor_flip(unsigned int curs1, unsigned int
  787.                          curs2);
  788.     
  789.     Prototype in         video.h
  790.     
  791.     Description          toggles the cursor scan lines to whichever set the
  792.                          cursor is not currently set for.
  793.     
  794.     Return value         nothing.
  795.     
  796.     See also             cursor_off(), cursor_on(), read_cursor(),
  797.                          set_cursor()
  798.     
  799.     Example              #include <video.h>
  800.     
  801.                          main()
  802.                          {
  803.                          cursor_flip(CURSOR_UNDERBAR,CURSOR_HALFBLOCK);
  804.                          }
  805.     
  806.     
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.                                                                    -13-
  848.  
  849.     
  850.     Name                  cursor_off - turn the cursor off
  851.     
  852.     Usage                void cursor_off(void);
  853.     
  854.     Prototype in         video.h
  855.     
  856.     Description          makes the cursor invisible.
  857.     
  858.     Return value         nothing.
  859.     
  860.     See also             cursor_flip(), cursor_on(), read_cursor(),
  861.                          set_cursor()
  862.     
  863.     Example              #include <video.h>
  864.     
  865.                          main()
  866.                          {
  867.                               cursor_off();
  868.                          }
  869.     
  870.     
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.                                                                    -14-
  914.  
  915.     
  916.     Name                  cursor_on - turn the cursor on
  917.     
  918.     Usage                void cursor_on(void);
  919.     
  920.     Prototype in         video.h
  921.     
  922.     Description          makes the cursor visible. Sets the scan lines to
  923.                          the default according to the hardware detected.
  924.     
  925.     Return value         nothing.
  926.     
  927.     See also             cursor_flip(), cursor_off(), read_cursor(),
  928.                          set_cursor()
  929.     
  930.     Example              #include <video.h>
  931.     
  932.                          main()
  933.                          {
  934.                               cursor_on();
  935.                          }
  936.     
  937.     
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.                                                                    -15-
  980.  
  981.     
  982.     Name                  dayofyear - calculate the day of the year
  983.     
  984.     Usage                int dayofyear(struct ddate *d);
  985.     
  986.     Prototype in         datehk.h
  987.     
  988.     Description          dayofyear calculate the day of the year given a
  989.                          date. The day of the year will range from 1
  990.                          (January 1) to 365 (Dec 31, no leap year) or 366
  991.                          (Dec 31, leap year.)
  992.     
  993.                          dayofyear does no error checking on passed
  994.                          parameters.
  995.     
  996.     Return value         returns a number from 1 to 365 (no leap year) or
  997.                          366 (leap year.)
  998.     
  999.     See also             daysleft(), diffddate()
  1000.     
  1001.     Example              #include <datehk.h>
  1002.     
  1003.                          main()
  1004.                          {
  1005.                               struct ddate today;
  1006.     
  1007.                               /* set today to Feb 3, 1987 */
  1008.                               printf("%d/%d = day %d\n", today.dmon,
  1009.                                    today.dday, dayofyear(&today));
  1010.                          }
  1011.     
  1012.     Program output       2/3 = day 34
  1013.     
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.                                                                    -16-
  1046.  
  1047.     
  1048.     Name                  daysleft - calculate the days left in the year
  1049.     
  1050.     Usage                int daysleft(struct ddate *d);
  1051.     
  1052.     Prototype in         datehk.h
  1053.     
  1054.     Description          daysleft calculates how many more days are left in
  1055.                          the year. The days left will range from 0 (Dec 31)
  1056.                          to 364 (Jan 1, no leap year) or 365 (Jan 1, leap
  1057.                          year.)
  1058.     
  1059.                          daysleft does no error checking on passed
  1060.                          parameters.
  1061.     
  1062.     Return value         returns a number from 0 to 364 (no leap year) or
  1063.                          365 (leap year.)
  1064.     
  1065.     See also             dayofyear(), diffddate()
  1066.     
  1067.     Example              #include <datehk.h>
  1068.     
  1069.                          main()
  1070.                          {
  1071.                               struct ddate today;
  1072.     
  1073.                               /* set today to Nov 3, 1987 */
  1074.                               printf("%d/%d = %d days left\n", today.dmon,
  1075.                                    today.dday, daysleft(&today));
  1076.                          }
  1077.     
  1078.     Program output       11/3 = 58 days left
  1079.     
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.                                                                    -17-
  1112.  
  1113.     
  1114.     Name                  ddatetolong - convert a date to long string
  1115.     
  1116.     Usage                char *ddatetolong(struct ddate *source); 
  1117.     
  1118.     Prototype in         datehk.h
  1119.     
  1120.     Description          ddatetolong converts a date from the structure
  1121.                          format ddate to a string in the form
  1122.                               Month dd, Year  where
  1123.     
  1124.                               Month = the name of the month ("November")
  1125.                               dd    = the day (5, 12, etc.)
  1126.                               Year  = the year + 1900
  1127.     
  1128.     Return value         returns a pointer to the storage location
  1129.                          containing the date in string format, or NULL if
  1130.                          space could not be allocated.
  1131.     
  1132.     See also             ddatetoshort(), ddatetostr(), monthexpand(),
  1133.                          strtoddate()
  1134.     
  1135.     Example              #include <datehk.h>
  1136.     
  1137.                          main()
  1138.                          {
  1139.                               struct ddate today;
  1140.                               char *strtoday;
  1141.     
  1142.                          /* assign some value to today */
  1143.                               strtoday = ddatetolong(&today);
  1144.                               printf("today is %d-%d-%d\n", today.dmon,
  1145.                                    today.dday, today.dyear);
  1146.                               printf("or %s\n", (strtoday==NULL) ?
  1147.                                    "no memory" : strtoday);
  1148.                          }
  1149.     
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.                                                                    -18-
  1178.  
  1179.     
  1180.     Name                  ddatetoshort - convert a date to long string
  1181.     
  1182.     Usage                char *ddatetoshort(struct ddate *source); 
  1183.     
  1184.     Prototype in         datehk.h
  1185.     
  1186.     Description          ddatetoshort converts a date from the structure
  1187.                          format ddate to a string in the form
  1188.                               Mon dd, Year  where
  1189.     
  1190.                               Mon  = the abbreviation of the month ("Nov")
  1191.                               dd   = the day (5, 12, etc.)
  1192.                               Year = the year + 1900
  1193.     
  1194.     Return value         returns a pointer to the storage location
  1195.                          containing the date in string format, or NULL if
  1196.                          space could not be allocated.
  1197.     
  1198.     See also             ddatetolong(), ddatetostr(), monthexpand(),
  1199.                          strtoddate()
  1200.     
  1201.     Example              #include <datehk.h>
  1202.     
  1203.                          main()
  1204.                          {
  1205.                               struct ddate today;
  1206.                               char *strtoday;
  1207.     
  1208.                          /* assign some value to today */
  1209.                               strtoday = ddatetoshort(&today);
  1210.                               printf("today is %d-%d-%d\n", today.dmon,
  1211.                                    today.dday, today.dyear);
  1212.                               printf("or %s\n", (strtoday==NULL) ?
  1213.                                    "no memory" : strtoday);
  1214.                          }
  1215.     
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.                                                                    -19-
  1244.  
  1245.     
  1246.     Name                  ddatetostr - convert a date to abbrev. string
  1247.     
  1248.     Usage                char *ddatetostr(struct ddate *source);
  1249.     
  1250.     Prototype in         datehk.h
  1251.     
  1252.     Description          ddatetostr converts a date from the structure
  1253.                          format ddate to a string in the form mm-dd-y..y
  1254.                          where the month and day are always 2 digits long
  1255.                          (a 0 is prefix to single digit months and days)
  1256.                          and year is not altered.
  1257.     
  1258.     Return value         returns a pointer to the storage location
  1259.                          containing the date in string format, or NULL if
  1260.                          space could not be allocated.
  1261.     
  1262.     See also             ddatetolong(), ddatetoshort(), monthexpand(),
  1263.                          strtoddate()
  1264.     
  1265.     Example              #include <datehk.h>
  1266.     
  1267.                          main()
  1268.                          {
  1269.                               struct ddate today;
  1270.                               char *strtoday;
  1271.     
  1272.                          /* assign some value to today */
  1273.                               strtoday = ddatetostr(&today);
  1274.                               printf("today is %d-%d-%d\n", today.dmon,
  1275.                                    today.dday, today.dyear);
  1276.                               printf("or %s\n", (strtoday==NULL) ?
  1277.                                    "no memory" : strtoday);
  1278.                          }
  1279.     
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.                                                                    -20-
  1310.  
  1311.     
  1312.     Name                  delay - wait for a time delay
  1313.     
  1314.     Usage                void delay(int wait);
  1315.     
  1316.     Prototype in         timehk.h
  1317.     
  1318.     Description          delay is an empty loop based on the clock that
  1319.                          waits for wait/10 seconds.
  1320.     
  1321.                          wait can be any positive int value (the maximium
  1322.                          wait 32767 is a little less than an hour.) If wait
  1323.                          is negative, erratic behavior may result (it won't
  1324.                          work.)
  1325.     
  1326.     Return value         nothing.
  1327.     
  1328.     Example              #include <timehk.h>
  1329.     
  1330.                          main()
  1331.                          {
  1332.                               delay(5);     /* wait for 1/2 second */
  1333.                               delay(600);   /* wait for one minute */
  1334.     
  1335.     
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.                                                                    -21-
  1376.  
  1377.     
  1378.     Name                  diffddate - calculate the difference in 2 dates
  1379.     
  1380.     Usage                long int diffddate(struct ddate *start,
  1381.                                              struct ddate *fini);
  1382.     
  1383.     Prototype in         datehk.h
  1384.     
  1385.     Description          diffdate calculates the difference in days between
  1386.                          start and fini (fini - start).
  1387.     
  1388.                          diffdate does not perform any error checking on
  1389.                          the passed parameters.
  1390.     
  1391.     Return value         returns the number of days from start to fini.
  1392.     
  1393.     See also             dayofyear(), daysleft(), diffddate()
  1394.     
  1395.     Example              #include <datehk.h>
  1396.     
  1397.                          main()
  1398.                          {
  1399.                               struct ddate begin, end;
  1400.                               long int days;
  1401.     
  1402.                               /* set begin to Jan 1, 1981 */
  1403.                               /* set end to Feb 5, 1982 */
  1404.                               days = diffdate(&begin,&end);
  1405.                               printf("Feb 5, 1982 - Jan 1, 1981 =
  1406.                                    %ld\n",days);
  1407.                          }
  1408.     
  1409.     Program output       Feb 5, 1982 - Jan 1, 1981 = 400
  1410.     
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.                                                                    -22-
  1442.  
  1443.     
  1444.     Name                  getc_match - get specific input,  case
  1445.                          independent
  1446.                           getk_match - get specific input, case dependent
  1447.     
  1448.     Usage                char getc_match(boolean output, char *match);
  1449.                          char getk_match(boolean output, char *match);
  1450.     
  1451.     Prototype in         keyboard.h
  1452.     
  1453.     Description          these functions accept character input (via
  1454.                          getk()) until one of the characters in the string
  1455.                          match in entered. getk_match waits for an
  1456.                          identical match ('a' != 'A') and getc_match waits
  1457.                          for a similar match ('a' == 'A'). Extended keys
  1458.                          never match (F10 will never be a match.) If output
  1459.                          = TRUE, the character is echoed to the screen via
  1460.                          putk().
  1461.     
  1462.     Return value         returns the key pressed.
  1463.     
  1464.     See also             getk(), getlogical(), getyn()
  1465.     
  1466.     Example              #include <keyboard.h>
  1467.     
  1468.                          main()
  1469.                          {
  1470.                               printf("Enter your choice (Q, X, F, D): ");
  1471.                               getc_match(1,"QXFD");
  1472.                               printf("Enter your sub-choice (abcdHJ): ");
  1473.                               getk_match(1,"abcdHJ");
  1474.                          }
  1475.     
  1476.     Program output       Enter your choice (Q, X, F, D): f
  1477.                          Enter your subchoice (abcdHJ): H
  1478.     
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.                                                                    -23-
  1508.  
  1509.     
  1510.     Name                  getddate - inputs a date from the keyboard
  1511.     
  1512.     Usage                char *getddate(void);
  1513.     
  1514.     Prototype in         keyboard.h
  1515.     
  1516.     Description          getddate inputs a date from the keyboard in the
  1517.                          form xx-xx-xx. Only digits, space and backspace
  1518.                          are valid input. Input is terminated when the
  1519.                          ENTER key is pressed. Input is echoed to the
  1520.                          screen via putk().
  1521.     
  1522.     Return value         if a valid date is entered, getddate returns a
  1523.                          string in the form xx-xx-xx, otherwise NULL is
  1524.                          returned.
  1525.     
  1526.     Example              #include <keyboard.h>
  1527.                          #include <stdio.h>
  1528.                          main()
  1529.                          {
  1530.                               char *c;
  1531.     
  1532.                               printf("What is today's date: ");
  1533.                               c = getddate();
  1534.                               printf("Today is %s\n",c);
  1535.                          }
  1536.     
  1537.     Program output       What is today's date: 11-10-87
  1538.                          Today is 11-10-87
  1539.     
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.                                                                    -24-
  1574.  
  1575.     
  1576.     Name                  getdouble - inputs a double from the keyboard
  1577.     
  1578.     Usage                char *getdouble(void);
  1579.     
  1580.     Prototype in         keyboard.h
  1581.     
  1582.     Description          getdouble inputs a double from the keyboard. Only
  1583.                          digits, decimal point, leading sign and backspace
  1584.                          are valid input. Input is terminated when the
  1585.                          ENTER key is pressed. Input is echoed to the
  1586.                          screen via putk().
  1587.     
  1588.                          The maximum length of input is 25.
  1589.     
  1590.     Return value         returns a string of the format    [sn] [ddd] [.]
  1591.                          [ddd] where
  1592.     
  1593.                               [sn]  = optional sign (+ or -)
  1594.                               [ddd] = optional digits
  1595.                               [.]   = optional decimal point
  1596.     
  1597.     See also             getint(), getreal()
  1598.     
  1599.     Example              #include <keyboard.h>
  1600.                          #include <stdio.h>
  1601.                          main()
  1602.                          {
  1603.                               char *c;
  1604.     
  1605.                               printf("Give me a double: ");
  1606.                               c = getdouble();
  1607.                               printf("Your input is %s\n",c);
  1608.                          }
  1609.     
  1610.     Program output       Give me a double: -1289.12003
  1611.                          Your input is -1289.12003
  1612.     
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.                                                                    -25-
  1640.  
  1641.     
  1642.     Name                  getfname - get a filename from the keyboard
  1643.     
  1644.     Usage                int getfname(byte row, byte col, char *returnstr,
  1645.                                    char *pattern, int argn, int argk[]);
  1646.     
  1647.     Prototype in         video.h
  1648.     
  1649.     Description          getfname calls getget() asking for input of a
  1650.                          length 12 string, at the coordinates (col,row),
  1651.                          including pattern formatting and optional input
  1652.                          exit keys listed in argk. If memory was allocated
  1653.                          for returnstr, the string pointed to by returnstr
  1654.                          is checked to see if it is a valid DOS filename. A
  1655.                          valid filename must be of the form
  1656.                              [filename] [.] [ext]    and does not contain
  1657.                          any of the following:
  1658.     
  1659.                               [ ] ; , . / ? * : " + = - < > \ |
  1660.     
  1661.                          If memory could not be allocated for the string,
  1662.                          returnstr will be set to NULL.
  1663.     
  1664.                          For more info on pattern and argk requirements,
  1665.                          check the stats for getget().
  1666.     
  1667.     Return value         if memory could not be allocated for returnstr or
  1668.                          the string pointed to by returnstr is not a valid
  1669.                          filename, -1 is returned, otherwise the key used
  1670.                          to exit the input is returned.
  1671.     
  1672.     See also             getget()
  1673.     
  1674.     Example              #include <filehk.h>
  1675.                          #include <keycode.h>
  1676.     
  1677.                          main()
  1678.                          {
  1679.                               char *fname;
  1680.                               int keys[2]={ESC,F10};  /* ESC & F10 exit
  1681.                               input */
  1682.     
  1683.                               gotoxy(0,0);
  1684.                               printf("Enter file: ");
  1685.                               if (getfname(0,13,fname,"!",2,keys) == -1)
  1686.                                    printf("    BAD FILENAME");
  1687.                               else
  1688.                                    printf("    valid filename");
  1689.                          }
  1690.     
  1691.     Program output       
  1692.     
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.                                                                    -26-
  1706.  
  1707.     
  1708.     Name                  getget - get a string from the keyboard
  1709.                          w/editing
  1710.     
  1711.     Usage                int getget(byte row, byte col, char *returnstr,
  1712.                                         int size, char *pattern, int argn,
  1713.                                         int argk[]);
  1714.     
  1715.     Prototype in         keyboard.h
  1716.     
  1717.     Description          getget inputs a string at coordinates (col,row),
  1718.                          of maximum length size, formatted according to
  1719.                          pattern. Input ends when ENTER or one of the scan
  1720.                          codes specified in argk[] in inputted. There are
  1721.                          argn number of elements in argk[]. The string is
  1722.                          returned in returnstr and the function returns the
  1723.                          scan code of the exiting key.
  1724.     
  1725.                          Full feature editing of the string includes:
  1726.     
  1727.                              ENTER           Ends input, exits function
  1728.                              BACKSPACE       normal backspace
  1729.                              LEFT ARROW      move cursor back 1 character
  1730.                              INSERT          toggle inset/overwrite mode
  1731.                              DELETE          delete character under cursor
  1732.                              RIGHT ARROW     move cursor forward 1
  1733.                                              character
  1734.                              HOME            move cursor to beginning for
  1735.                                              string
  1736.                              END             move cursor to end of string
  1737.                              CTRL-Y          delete entire string
  1738.                              ALT-Y           delete string from cursor to
  1739.                                              end
  1740.     
  1741.                          See getstr() for pattern arguments.
  1742.     
  1743.     Return value         returns the scan code of the key causing the exit
  1744.     
  1745.     See also             getstr()
  1746.     
  1747.     
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.                                                                    -27-
  1772.  
  1773.     
  1774.     Name                  getint - inputs an integer from the keyboard
  1775.     
  1776.     Usage                char *getint(void);
  1777.     
  1778.     Prototype in         keyboard.h
  1779.     
  1780.     Description          getint inputs an integer from the keyboard. Only
  1781.                          digits, leading sign and backspace are valid
  1782.                          input. Input is terminated when the ENTER key is
  1783.                          pressed. Input is echoed to the screen via putk().
  1784.     
  1785.                         the maximum length of input is 25.
  1786.     
  1787.     Return value         returns a string of the format  [sn] [ddd]  where
  1788.     
  1789.                               [sn]  = optional sign (+ or -)
  1790.                               [ddd] = optional digits
  1791.     
  1792.     See also             getdouble(), getreal()
  1793.     
  1794.     Example              #include <keyboard.h>
  1795.                          #include <stdio.h>
  1796.                          main()
  1797.                          {
  1798.                               char *c;
  1799.     
  1800.                               printf("Give me an integer: ");
  1801.                               c = getint();
  1802.                               printf("Your input is %s\n",c);
  1803.                          }
  1804.     
  1805.     Program output       Give me an integer: -1289
  1806.                          Your input is -1289
  1807.     
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.                                                                    -28-
  1838.  
  1839.     
  1840.     Name                  getk - get a key
  1841.     
  1842.     Usage                byte getk(boolean wait);
  1843.     
  1844.     Prototype in         keyboard.h
  1845.     
  1846.     Description          getk returns the scan code of the key pressed. If
  1847.                          no key was pressed (WAIT = FALSE) 0 is returned.
  1848.                          This function is similar to getchar() except input
  1849.                          is not echoed to the screen and getk will detect
  1850.                          any key press (any standard keypress. It cannot
  1851.                          distinguish between the grey '+' key and the white
  1852.                          '+'. This function is interrupt driven. It will
  1853.                          detect ALT combinations, Del, PgUp, function keys,
  1854.                          etc., any keyboard INTerrupt accepted keys.
  1855.     
  1856.     Return value         returns the scancode for the key pressed, from 1
  1857.                          to 255. If WAIT = FALSE, and no key is pressed,
  1858.                          zero is returned. Check the global variables
  1859.                          key_status and key_extended to determine the shift
  1860.                          key status and if the key is an extended one.
  1861.     
  1862.     See also             keycode.h
  1863.                          getc_match(), getk_match(), getlogical(), getyn(),
  1864.                          inkey()
  1865.     
  1866.     Example              #include <keyboard.h>
  1867.                          #include <stdio.h>
  1868.     
  1869.                          main()
  1870.                          {
  1871.                               extern boolean key_extended;
  1872.                               byte c;
  1873.     
  1874.                               c = getk(WAIT);
  1875.                               printf("Key code # in keycode.h: %d\n",
  1876.                                    key_extended ? c+256 : c);
  1877.                          }
  1878.     
  1879.     
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.                                                                    -29-
  1904.  
  1905.     
  1906.     Name                  getlogical - get Yes/No
  1907.     
  1908.     Usage                char getlogical(int output);
  1909.     
  1910.     Prototype in         keyboard.h
  1911.     
  1912.     Description          getlogical waits for a True/False key (TtFfYyNn)
  1913.                          to be pressed and then displays a message via
  1914.                          putstr() according to output:
  1915.     
  1916.                               output         Message displayed
  1917.                               ------         -----------------
  1918.                                 0               no message
  1919.                                 1                T or F or Y or N
  1920.                                 2                True or False or Yes or No
  1921.     
  1922.                          getlogical is case independent.
  1923.     
  1924.     Return value         returns 'Y' or 'N'
  1925.     
  1926.     See also             getc_match(), getk(), getk_match(), getyn(),
  1927.                          inkey()
  1928.     
  1929.     Example              #include <keyboard.h>
  1930.     
  1931.                          main()
  1932.                          {
  1933.                               printf("This is good? ");
  1934.                               getlogical(2);
  1935.                          }
  1936.     
  1937.     
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.                                                                    -30-
  1970.  
  1971.     
  1972.     Name                  getreal - inputs a real from the keyboard
  1973.     
  1974.     Usage                char *getreal(int size, int decimal);
  1975.     
  1976.     Prototype in         keyboard.h
  1977.     
  1978.     Description          getreal inputs a real (double) from the keyboard.
  1979.                          Only digits, decimal place, leading sign and
  1980.                          backspace are valid input. Input is terminated
  1981.                          when the ENTER key is pressed. Input is echoed to
  1982.                          the screen via putk().
  1983.     
  1984.                          the maximum length of input is size and the
  1985.                          maximum number of decimal places is decimal. When
  1986.                          calculating size, you must leave enough room for
  1987.                          decimal, plus the number of places of the leading
  1988.                          integer, one for the decimal point and one for the
  1989.                          leading sign.
  1990.     
  1991.     Return value         returns a string of the format  [sn] [ddd] [.]
  1992.                          [ddd] where
  1993.     
  1994.                               [sn]  = optional sign (+ or -)
  1995.                               [ddd] = optional digits
  1996.                               [.]   = optional decimal point
  1997.     
  1998.     See also             getdouble(), getint()
  1999.     
  2000.     Example              #include <keyboard.h>
  2001.                          #include <stdio.h>
  2002.                          main()
  2003.                          {
  2004.                               char *c;
  2005.     
  2006.                               printf("Give me a real: ");
  2007.                               c = getreal(8,2);
  2008.                               printf("Your input is %s\n",c);
  2009.                          }
  2010.     
  2011.     Program output       Give me a real: -1012.30
  2012.                          Your input is -1012.30
  2013.     
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.                                                                    -31-
  2036.  
  2037.     
  2038.     Name                  getstr - input a string from the keyboard
  2039.     
  2040.     Usage                char *getstr(int size, char *pattern);
  2041.     
  2042.     Prototype in         keyboard.h
  2043.     
  2044.     Description          getstr inputs a string from the keyboard, of
  2045.                          maximum length size, given a format pattern where
  2046.     
  2047.                                     pattern       format
  2048.                                     -------       ------
  2049.                          Types          a         Alphabetic
  2050.                                         A         Alphabetic and
  2051.                                                   capitalized
  2052.                                         n         Alphanumeric
  2053.                                         N         Alphanumeric and
  2054.                                                   capitalized
  2055.                                         X         Ascii (default)
  2056.                                         9         Numeric
  2057.                                         #         Numeric and punctuation
  2058.     
  2059.                          Modifiers      !         convert to upper case
  2060.                                         .         punctuation
  2061.                                         (         left justify
  2062.                                         )         right justify
  2063.                                         ^         center justify
  2064.     
  2065.                          The only other valid keys are backspace and ENTER.
  2066.                          Input is echoed to the screen via putk().
  2067.     
  2068.     Return value         returns a pointer to the storage location
  2069.                          containing the formatted string, or NULL if space
  2070.                          could not be allocated.
  2071.     
  2072.     See also             getget()
  2073.     
  2074.     Example              #include <keyboard.h>
  2075.                          #include <stdio.h>
  2076.     
  2077.                          main()
  2078.                          {
  2079.                               char *f, *l, *s, *c;
  2080.     
  2081.                               printf("First name: ");
  2082.                               f = getget(10,"A");
  2083.                               printf("Last name: ");
  2084.                               l = getget(20,"a");
  2085.                               printf("SS#: ");
  2086.                               s = getget(8,"9");
  2087.                               printf("Comments: ");
  2088.                               c = getget(60,"");
  2089.                          }
  2090.     
  2091.     Program output       First name: HOWARD
  2092.                          Last name: kapustein
  2093.                          SS#: 123456789
  2094.                          Comments: The empty quotes defaults to X.
  2095.     
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.                                                                    -32-
  2102.  
  2103.     
  2104.     Name                  getyn - get Yes/No
  2105.     
  2106.     Usage                char getyn(int output);
  2107.     
  2108.     Prototype in         keyboard.h
  2109.     
  2110.     Description          getyn waits for a Y or N to be pressed and then
  2111.                          displays a message via putstr() according to
  2112.                          output:
  2113.     
  2114.                               output         Message displayed
  2115.                               ------         -----------------
  2116.                                 0               no message
  2117.                                 1                Y or N
  2118.                                 2                Yes or No
  2119.     
  2120.                          getyn is case independent.
  2121.     
  2122.     Return value         returns 'Y' or 'N'
  2123.     
  2124.     See also             getc_match(), getk(), getk_match(), getlogical(),
  2125.                          inkey()
  2126.     
  2127.     Example              #include <keyboard.h>
  2128.     
  2129.                          main()
  2130.                          {
  2131.                               printf("Is this OK? ");
  2132.                               getyn(2);
  2133.                          }
  2134.     
  2135.     
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.                                                                    -33-
  2168.  
  2169.     
  2170.     Name                  gotoxy - move cursor to coordinates (x,y)
  2171.     
  2172.     Usage                void gotoxy(int x, int y);
  2173.     
  2174.     Prototype in         video.h
  2175.     
  2176.     Description          gotoxy puts cursor at coordinates (x,y) via INT
  2177.                          0x10, Service 2.
  2178.     
  2179.     Return value         nothing.
  2180.     
  2181.     See also             read_cursor(), wherex(), wherey()
  2182.     
  2183.     Example              #include <video.h>
  2184.     
  2185.                          main()
  2186.                          {
  2187.                               gotoxy(4,10);   /* put cursor at row 4,
  2188.                               column 10 */
  2189.                          }
  2190.     
  2191.     
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.                                                                    -34-
  2234.  
  2235.     
  2236.     Name                  horiz_line - draw a horizontal line
  2237.     
  2238.     Usage                void horiz_line(byte c, unsigned int len, byte
  2239.                          row,
  2240.                                         byte col);
  2241.     
  2242.     Prototype in         video.h
  2243.     
  2244.     Description          draws a horizontal line of characters c of length
  2245.                          len beginning at (col,row) via INTerrupts.
  2246.     
  2247.                          horiz_line does no error checking on the passed
  2248.                          parameters.
  2249.     
  2250.     Return value         nothing.
  2251.     
  2252.     See also             box(), restore_box(), restore_screen(),
  2253.                          save_box(), save_screen(), vert_line()
  2254.     
  2255.     Example              #include <video.h>
  2256.     
  2257.                          main()
  2258.                          {
  2259.                               horiz_line('*',7,4,4);  /* draw 7 *'s at
  2260.                               (4,4) */
  2261.                          }
  2262.     
  2263.     
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.                                                                    -35-
  2300.  
  2301.     
  2302.     Name                  inkey - get a key
  2303.     
  2304.     Usage                int inkey(boolean wait);
  2305.     
  2306.     Prototype in         keyboard.h
  2307.     
  2308.     Description          inkey returns the scan code of the key pressed. If
  2309.                          no key was pressed (WAIT = FALSE) 0 is returned.
  2310.                          This function is similar to getchar() except input
  2311.                          is not echoed to the screen and getk will detect
  2312.                          any key press (any standard keypress. It cannot
  2313.                          distinguish between the grey '+' key and the white
  2314.                          '+'. This function is interrupt driven. It will
  2315.                          detect ALT combinations, Del, PgUp, function keys,
  2316.                          etc., any keyboard INTerrupt accepted keys.
  2317.     /* IBM.c  -  IBM specific info functions: machine ID, etc. */
  2318.  
  2319. #include <howard.h>
  2320. #include <dos.h>
  2321. #include <ibm.h>
  2322. #include <alloc.h>
  2323. #include <stdio.h>
  2324.  
  2325.  
  2326. /* function prototypes */
  2327. byte IBM_id(void);                     /* get ROM id */
  2328. char *IBM_date(void);                  /* get ROM date */
  2329. boolean isEMSavail(void);              /* is EMS available */
  2330. /*void reboot(boolean warmboot);         /* reboot, warmboot vs. coldboot */*/
  2331.  
  2332.  
  2333. byte ROM_id(void)                      /* get ROM id */
  2334. {
  2335.     return (peekb(0xF000, 0xFFFE));
  2336. }
  2337.  
  2338.  
  2339. char *ROM_date(void)                      /* get ROM date */
  2340. {
  2341.     int i;
  2342.     char *retval;
  2343.  
  2344.     if ((retval = (char *) calloc (9,sizeof(char))) == NULL)
  2345.        return(NULL);
  2346.     for (i=0; i<8; i++)
  2347.         *(retval+i) = peekb(0xF000, 0xFFF5 + i);
  2348.     *(retval+8) = '\0';
  2349.     return(retval);
  2350. }
  2351. /*
  2352.  
  2353. void reboot(boolean warmboot)          /* reboot, warmboot vs. coldboot */
  2354. {
  2355.     int *bootme();
  2356.  
  2357.     if (warmboot)
  2358.         *((int far *) 0x472lu) = 0x1234;    /* forces warm boot */
  2359.  
  2360.     (long)bootme = 0xFFFF0000l;   /*  segment:offset addr of BIOS RAM (FFFF:0000) */
  2361.     (*bootme)();                            /* reboot */
  2362. }
  2363. */
  2364.  
  2365.  
  2366. boolean isEMSavail(void)               /* is EMS available */
  2367. {
  2368.     FILE *fp;
  2369.  
  2370.     if ((fp = fopen("EMMXXXX0","r")) == NULL)   /* no EMS device */
  2371.         return(FALSE);
  2372.     fclose(fp);                   /* close opened EMS device */
  2373.     return(TRUE);
  2374. }
  2375.  
  2376.  
  2377. main(){printf("EMS: %d\n",isEMSavail()?1:0);}╒UU └%UUUU≡
  2378. Ñ⌡UU_T? µU_⌡TuP  µ¬¬_╒_  ┴@U  σ¬¬ UL╠@UU   σ¬⌐w ⌡
  2379. U▀ ╫σUÑ⌡_⌡UUTU²UUò⌡}╒U_╫⌡UUW╒≈╒T²_UuU_W╫UUu
  2380. U⌡U_}U└ÇZájá
  2381. ⌐`iÇUP²VUUUU]UUUYW_UUUeUUU?≡UUUZ\ ▀└UTU\? ╫≡▌UU    
  2382.     Return value         returns the scancode for the key pressed, from 1
  2383.                          to 511. If WAIT = FALSE, and no key is pressed,
  2384.                          zero is returned.
  2385.     
  2386.     See also             keycode.h
  2387.     See also             getc_match(), getk(), getk_match(), getlogical(),
  2388.                          getyn()
  2389.     
  2390.     Example              #include <keyboard.h>
  2391.                          #include <stdio.h>
  2392.     
  2393.                          main()
  2394.                          {
  2395.                               int c;
  2396.     
  2397.                               c = inkey(WAIT);
  2398.                               printf("Key code # in keycode.h: %d\n", c);
  2399.                          }
  2400.     
  2401.     
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.                                                                    -36-
  2430.  
  2431.     
  2432.     Name                  intlen - calculate length of integer in a string
  2433.     
  2434.     Usage                int intlen(char *number);
  2435.     
  2436.     Prototype in         stringhk.h
  2437.     
  2438.     Description          intlen calculates the length of an integer in the
  2439.                          string number. The integer is terminated by a
  2440.                          non-digit (any character other than 0-9.) This
  2441.                          function is used internally by strcomma.
  2442.     
  2443.     Return value         the length of the integer pointed to by number.
  2444.     
  2445.     Example              #include <stringhk.h>
  2446.                          #include <stdio.h>           /* for the printf */
  2447.                          #include <alloc.h>           /* for the calloc */
  2448.     
  2449.                          main()
  2450.                          {
  2451.                               char *sint[15];
  2452.                               int len;
  2453.     
  2454.                               strcpy(sint,"1839.44");
  2455.                               printf("String: %s    Length of integer:
  2456.                               %d\n", sint, intlen(sint));
  2457.                               strcpy(sint,"19,848");
  2458.                               printf("String: %s    Length of integer:
  2459.                               %d\n", sint, intlen(sint));
  2460.                               strcpy(sint,"44x993");
  2461.                               printf("String: %s    Length of integer:
  2462.                               %d\n", sint, intlen(sint));
  2463.                          }
  2464.     
  2465.     Program output       String: 1839.44    Length of integer: 4
  2466.                          String: 19,848    Length of integer: 2
  2467.                          String: 44x993    Length of integer: 2
  2468.     
  2469.     
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.                                                                    -37-
  2496.  
  2497.     
  2498.     Name                  isCGA - is Color Graphics adapter installed
  2499.                           isEGA - is Enhanced Graphics adapter installed
  2500.                           isHerc - is Hercules Graphics adapter installed
  2501.                           isMDA - is Monochrome adapter installed
  2502.     
  2503.                          ismono - is monochrome display
  2504.                          iscolor - is color display
  2505.     
  2506.     Usage                boolean isMDA(void);
  2507.                          boolean isCGA(void);
  2508.                          boolean isEGA(void);
  2509.                          boolean isHerc(void);
  2510.     
  2511.                          boolean ismono(void);
  2512.                          boolean iscolor(void);
  2513.     
  2514.     Prototype in         video.h
  2515.     
  2516.     Description          is...() check if a video adapter is present.
  2517.                          ismono() checks if the display is mono.
  2518.                          iscolor() checks if the display is color.
  2519.     
  2520.                          The ismono() and iscolor() are combinations. Use
  2521.                          them if you wish to check what attributes to use
  2522.                          (underline or red?) and use the adapter functions
  2523.                          (isEGA, etc.) for adapter specific tests.
  2524.     
  2525.     Return value         these functions return TRUE if the video adapter
  2526.                          or type, as the case may be, is present. Otherwise
  2527.                          they return FALSE.
  2528.     
  2529.     See also             video.h
  2530.     
  2531.     Example              #include <video.h>
  2532.     
  2533.                          main()
  2534.                          {
  2535.                               if (ismono())           /* monochrome */
  2536.                                    if (isHerc())
  2537.                                         printf("Hercules");
  2538.                                    else
  2539.                                         printf("MDA");
  2540.                               else                    /* color */
  2541.                                    if (isEGA())
  2542.                                         printf("EGA");
  2543.                                    else
  2544.                                         printf("CGA");
  2545.                          }
  2546.     
  2547.     
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.                                                                    -38-
  2562.  
  2563.     
  2564.     Name                  isEMSavail - is EMS available
  2565.     
  2566.     Usage                boolean isEMSavail(void);
  2567.     
  2568.     Prototype in         ibm.h
  2569.     
  2570.     Description          checks if an EMS device is installed.
  2571.     
  2572.     Return value         returns TRUE if EMS is present, otherwise FALSE.
  2573.     
  2574.     Example              #include <ibm.h>
  2575.     
  2576.                          main()
  2577.                          {
  2578.                               printf("EMS is ");
  2579.                               if (! isEMSavail())
  2580.                                    printf("not ");
  2581.                               printf("available\n");
  2582.                          }
  2583.     
  2584.     
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.                                                                    -39-
  2628.  
  2629.     
  2630.     Name                  isleapyear - is a year a leap year
  2631.     
  2632.     Usage                boolean isleapyear(int checkyear);
  2633.     
  2634.     Prototype in         datehk.h
  2635.     
  2636.     Description          checks if checkyear is a leap year (29 days in
  2637.                          February.)
  2638.     
  2639.     Return value         returns TRUE if checkyear is a leap year, FALSE
  2640.                          otherwise.
  2641.     
  2642.     See also             valid_date()
  2643.     
  2644.     Example              #include <datehk.h>
  2645.     
  2646.                          main()
  2647.                          {
  2648.                               int year;
  2649.     
  2650.                          /* assign some value to year */
  2651.                               printf("year %d is ",year);
  2652.                               if (! isleapyear(year))
  2653.                                    printf("not ");
  2654.                               printf("a leap year\n");
  2655.                          }
  2656.     
  2657.     
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.                                                                    -40-
  2694.  
  2695.     
  2696.     Name                  leftstr - return the left portion of string
  2697.                           midstr - return a piece of a string
  2698.                           rightstr - return the right portion of a string
  2699.     
  2700.     Usage                char *leftstr(char *source, int len);
  2701.                          char *midstr(char *source, int begin, int len);
  2702.                          char *rightstr(char *source, int len);
  2703.     
  2704.     Prototype in         stringhk.h
  2705.     
  2706.     Description          these functions perform just like their BASIC
  2707.                          counterparts LEFT$(), RIGHT$() and MID$(). 
  2708.     
  2709.                          leftstr returns the left part of a string.
  2710.                          midstr returns the middle part of a string.
  2711.                          rightstr returns the right part of a string.
  2712.     
  2713.     Return value         leftstr returns the leftmost len characters of
  2714.                          source. If the length of source is less than len,
  2715.                          the entire string is returned.
  2716.     
  2717.                          midstr returns the substring of source, using
  2718.                          begin as the offset from the beginning to start
  2719.                          the substring, for len characters.
  2720.     
  2721.                          rightstr returns the rightmost len characters of
  2722.                          source. If the length of source is less than len,
  2723.                          the entire string is returned.
  2724.     
  2725.                          All these functions return a pointer to the
  2726.                          storage location containing the new string, or
  2727.                          NULL if space could not be allocated.
  2728.     
  2729.     Example              #include <stringhk.h>
  2730.                          #include <stdio.h>           /* for the printf */
  2731.     
  2732.                          main()
  2733.                          {
  2734.                               char msg[25], *l, *r, *m;
  2735.     
  2736.                               strcpy(msg,"This is another test");
  2737.                               l = leftstr(msg,7);
  2738.                               r = right(msg,7);
  2739.                               m = midstr(msg,5,7);
  2740.                               printf("%s\n",msg);
  2741.                               printf("%s\n",l);
  2742.                               printf("%s\n",r);
  2743.                               printf("%s\n",m);
  2744.                          }
  2745.     
  2746.     Program output       This is another test
  2747.                          This an
  2748.                          er test
  2749.                          is anot
  2750.     
  2751.     
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.                                                                    -41-
  2760.  
  2761.     
  2762.     Name                  lotus_setup - creates info for menu_lotus()
  2763.     
  2764.     Usage                void lotus_setup(int argc, byte *command[],
  2765.                                    char cmdkey[], byte col[], byte
  2766.                                    *message[], byte msglen[]);
  2767.     
  2768.     Prototype in         menuhk.h
  2769.     
  2770.     Description          lotus_setup does a lot of the grunt work necessary
  2771.                          to use menu_lotus() properly. Given the command
  2772.                          and message lists this function will create
  2773.                          cmdkey[], col[] and msglen[].
  2774.     
  2775.     Return value         nothing.
  2776.     
  2777.     See also             menu_lotus()
  2778.     
  2779.     Example              see demo.c
  2780.     
  2781.     
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.                                                                    -42-
  2826.  
  2827.     
  2828.     Name                  menu_lotus - Lotus style menu
  2829.     
  2830.     Usage                char menu_lotus(int argc, char cmdkey[], byte
  2831.                          *command[],         byte col[], byte *message[],
  2832.                                              byte msglen[], byte normal,
  2833.                                              byte highlite, byte cmdrow,
  2834.                                              boolean clockon, byte
  2835.                                              clockrow, byte clockcol, byte
  2836.                                              clockcolor);
  2837.     
  2838.     Prototype in         menuhk.h
  2839.     
  2840.     Description          menu_lotus displays a Lotus style 'slash bar' menu
  2841.                          and waits for a menu selection. This function is
  2842.                          modeled after the slash bar menu in Symphony. The
  2843.                          function parameters are:
  2844.     
  2845.                               argc           number of menu choices
  2846.                               cmdkey         array of the 1st letter of
  2847.                                              each command (must be
  2848.                                              capitalized)
  2849.                               command        menu choices
  2850.                               col            columns of 1st letters of menu
  2851.                                              commands (for displaying
  2852.                                              command line)
  2853.                               message        respective messages for menu
  2854.                                              commands
  2855.                               msglen         lengths of messages
  2856.                               normal         color of text
  2857.                               highlite       color of highlited option
  2858.                               cmdrow         row to display command line on
  2859.                               clockon        flag: display a clock?
  2860.                               clockrow       row coordinate of clock
  2861.                               clockcol       column coordinate of clock
  2862.                               clockcolor     color of clock
  2863.     
  2864.                          menu_lotus will display an optional clock (clockon
  2865.                          = TRUE) that is updated every minute. The clock is
  2866.                          displayed as 11:44 PM.
  2867.     
  2868.                          All elements of cmdkey[] MUST be capitalized.
  2869.     
  2870.                          menu_lotus provides limited cursor control, as per
  2871.                          Symphony:
  2872.     
  2873.                               Up Arrow       \ move highlite left 1 choice
  2874.                               Left Arrow     /
  2875.                               Down Arrow     \ move highlite right 1 choice
  2876.                               Right Arrow    /
  2877.                               Home           highlites first command
  2878.                               End            highlites last command
  2879.                               Enter          selects highlited menu choice
  2880.                               ESCape         selects nothing. Returns ESC
  2881.                                              code
  2882.     
  2883.                          The cursor keys do not wraparound. Pressing right
  2884.                          arrow at the last menu choice does nothing.
  2885.     
  2886.                          All output is done via putstr().
  2887.     
  2888.  
  2889.  
  2890.  
  2891.                                                                    -43-
  2892.  
  2893.     
  2894.     Return value         returns the upper of the 1st letter of the menu
  2895.                          choice selected, or ESC (0x27) if ESC was pressed
  2896.     
  2897.     See also             lotus_setup()
  2898.     
  2899.     Example              see demo.c
  2900.     
  2901.     
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.                                                                    -44-
  2958.  
  2959.     
  2960.     Name                  monthexpand - convert a month abbrev to its name
  2961.     
  2962.     Usage                char *monthexpand(int month);
  2963.     
  2964.     Prototype in         datehk.h
  2965.     
  2966.     Description          monthexpand returns the name of a month given its
  2967.                          numeric abbreviation.
  2968.     
  2969.                          monthexpand returns an element of a static char
  2970.                          array, so you should not make any changes directly
  2971.                          to the returned value, but rather copy the
  2972.                          returned value to a safe piece of memory.
  2973.     
  2974.     Return value         returns a pointer to the storage location
  2975.                          containing the date structure, or NULL if the
  2976.                          month given is invalid.
  2977.     
  2978.     See also             ddatetolong(), ddatetoshort(), ddatetostr(),
  2979.                          monthexpand(), strtoddate()
  2980.     
  2981.     Example              #include <datehk.h>
  2982.     
  2983.                          main()
  2984.                          {
  2985.                               printf("Month 4 = %s\n",monthexpand(4));
  2986.                          }
  2987.     
  2988.     Program output       Month 4 = April
  2989.     
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.                                                                    -45-
  3024.  
  3025.     
  3026.     Name                  putk - put a character w/attribute on the screen
  3027.     
  3028.     Usage                void putk(byte c);
  3029.     
  3030.     Prototype in         video.h
  3031.     
  3032.     Description          putk puts character c on the screen at the cursor
  3033.                          via INTerrupts. The cursor does NOT advance. The
  3034.                          attribute is set with the global variable
  3035.                          char_attribute.
  3036.     
  3037.     Return value         nothing.
  3038.     
  3039.     See also             putsay(), putstr(), set_color()
  3040.     
  3041.     Example              #include <video.h>
  3042.     
  3043.                          main()
  3044.                          {
  3045.                               gotoxy(12,40);
  3046.                               putk('*');
  3047.                          }
  3048.     
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.                                                                    -46-
  3090.  
  3091.     
  3092.     Name                  putsay - put a string with attribute on the
  3093.                          screen
  3094.     
  3095.     Usage                void putsay(byte row, byte col, byte *c);
  3096.     
  3097.     Prototype in         video.h
  3098.     
  3099.     Description          putsay puts string c on the screen at location
  3100.                          (col,row) via direct screen writes. It does
  3101.                          retrace checking to prevent snow on CGA systems.
  3102.                          The attribute is set with the global variable
  3103.                          char_attribute.
  3104.     
  3105.     Return value         nothing.
  3106.     
  3107.     See also             putk(), putstr(), set_color()
  3108.     
  3109.     Example              #include <video.h>
  3110.     
  3111.                          main()
  3112.                          {
  3113.                               putstr(12,40,(byte *)"Hello");
  3114.                          }
  3115.     
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.                                                                    -47-
  3156.  
  3157.     
  3158.     Name                  putstr - put a string with attribute on the
  3159.                          screen
  3160.     
  3161.     Usage                void putstr(byte *c);
  3162.     
  3163.     Prototype in         video.h
  3164.     
  3165.     Description          putstr puts string c on the screen at the cursor
  3166.                          via INTerrupts. When finished the cursor will be 1
  3167.                          spot after the string. The attribute is set with
  3168.                          the global variable char_attribute.
  3169.     
  3170.     Return value         nothing.
  3171.     
  3172.     See also             putk(), putsay(), set_color()
  3173.     
  3174.     Example              #include <video.h>
  3175.     
  3176.                          main()
  3177.                          {
  3178.                               gotoxy(12,40);
  3179.                               putstr((byte *)"Hello");
  3180.                          }
  3181.     
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.                                                                    -48-
  3222.  
  3223.     
  3224.     Name                  read_cursor - reads cursor information
  3225.     
  3226.     Usage                unsigned int read_cursor(byte *row, byte *col);
  3227.     
  3228.     Prototype in         video.h
  3229.     
  3230.     Description          reads the cursor location and scan lines via
  3231.                          INTerrupts.
  3232.     
  3233.     Return value         returns the scan lines of the cursor as a word,
  3234.                          the high order byte the start and low order byte
  3235.                          the end.
  3236.     
  3237.     See also             cursor_flip(), cursor_off(), cursor_on(),
  3238.                          set_cursor(), wherex(), wherey()
  3239.     
  3240.     Example              #include <video.h>
  3241.     
  3242.                          main()
  3243.                          {
  3244.                               byte x,y;
  3245.                               unsigned int scan;
  3246.     
  3247.                               scan = read_cursor(&x,&y);
  3248.                               printf("Scan start %d and end %d\n",
  3249.                                    scan&0xFF00, scan&0xFF);
  3250.                          }
  3251.     
  3252.     Program output       Scan start 6 and end 7         /* on CGA */
  3253.     
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.                                                                    -49-
  3288.  
  3289.     
  3290.     Name                  read_mode - find screen width, mode and page
  3291.     
  3292.     Usage                void read_mode(byte *width, byte *mode, byte
  3293.                          *page);
  3294.     
  3295.     Prototype in         video.h
  3296.     
  3297.     Description          detects the screen width (number of columns,)
  3298.                          video mode and video page via INT 0x10, Service
  3299.                          0x0F.
  3300.     
  3301.     Return value         nothing.
  3302.     
  3303.     See also             video.h
  3304.                          set_mode()
  3305.     
  3306.     Example              #include <video.h>
  3307.     
  3308.                          main()
  3309.                          {
  3310.                               byte width, mode, page;
  3311.     
  3312.                               read_mode(&width, &mode, &page);
  3313.                               printf("# columns: %d    Mode: %d   Page:
  3314.                                    %d\n", width, mode, page);
  3315.                          }
  3316.     
  3317.     Program output       # columns: 80    Mode: 3   Page: 1
  3318.     
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.                                                                    -50-
  3354.  
  3355.     
  3356.     Name                  restore_box - restore a part of the screen
  3357.     
  3358.     Usage                void restore_box(byte top, byte left, byte bottom,
  3359.                                    byte right, byte *buffer);
  3360.     
  3361.     Prototype in         video.h
  3362.     
  3363.     Description          restore_box restores part of the current screen
  3364.                          (characters and attributes,) from a block of
  3365.                          memory to the display memory, over the area
  3366.                          delineated by the box coordinates.
  3367.     
  3368.                          restore_box will write buffer's contents to the
  3369.                          display memory over the location given by the box
  3370.                          coordinates. With this function it is possible to
  3371.                          restore a screen segment multiple times to
  3372.                          different areas of the screen, allowing quick
  3373.                          display of multiple images.
  3374.     
  3375.     Return value         nothing.
  3376.     
  3377.     See also             restore_box(), restore_screen(), restore_screen()
  3378.     
  3379.     Example              #include <video.h>
  3380.     
  3381.                          main()
  3382.                          {
  3383.                               byte buffer[0x2000];
  3384.     
  3385.                               save_box(0,0,25,39,buffer);
  3386.                               /* save left half of the screen */
  3387.                               restore_box(0,40,25,79,buffer);
  3388.                               /* restore it on the right half of screen */
  3389.                          }
  3390.     
  3391.     
  3392.  
  3393.  
  3394.  
  3395.  
  3396.  
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.                                                                    -51-
  3420.  
  3421.     
  3422.     Name                  restore_screen - restore screen
  3423.     
  3424.     Usage                void restore_screen(byte *buffer);
  3425.     
  3426.     Prototype in         video.h
  3427.     
  3428.     Description          restore_screen restores the current screen
  3429.                          (characters and attributes) from a block of
  3430.                          memory.
  3431.     
  3432.                          restore_screen will copy 4K from the memory
  3433.                          location pointed to by buffer to the display
  3434.                          memory.
  3435.     
  3436.     Return value         nothing.
  3437.     
  3438.     See also             restore_box(), restore_screen(), restore_box()
  3439.     
  3440.     Example              #include <video.h>
  3441.     
  3442.                          main()
  3443.                          {
  3444.                               byte buffer[0x4000];
  3445.     
  3446.                               save_screen(buffer);
  3447.                          /* display some stuff */
  3448.                               restore_screen(buffer);
  3449.                          }
  3450.     
  3451.     
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.                                                                    -52-
  3486.  
  3487.     
  3488.     Name                  ROM_date - gets the ROM id date
  3489.     
  3490.     Usage                byte ROM_date(void);
  3491.     
  3492.     Prototype in         ibm.h
  3493.     
  3494.     Description          finds the ROM id date at F000:FFF5
  3495.     
  3496.     Return value         returns a pointer to the storage location
  3497.                          containing the string, or NULL if space could not
  3498.                          be allocated.
  3499.     
  3500.     See also             ROM_id()
  3501.     
  3502.     Example              #include <ibm.h>
  3503.                          #include <stdio.h>
  3504.     
  3505.                          main()
  3506.                          {
  3507.                               printf("ROM BIOS date = %s",ROM_date());
  3508.                          }
  3509.     
  3510.     Program output       ROM BIOS date = 06/10/85
  3511.     
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.                                                                    -53-
  3552.  
  3553.     
  3554.     Name                  ROM_id - gets the ROM id byte
  3555.     
  3556.     Usage                byte ROM_id(void);
  3557.     
  3558.     Prototype in         ibm.h
  3559.     
  3560.     Description          finds the ROM id byte at F000:FFFE
  3561.     
  3562.     Return value         returns the ROM id byte
  3563.     
  3564.     Note                 on Compaq machines the ROM id byte is found at a
  3565.                          memory location close to, but not at, F000:FFFE.
  3566.                          Not having access to a Compaq, I did not include a
  3567.                          check for this. Maybe a future version...
  3568.     
  3569.     See also             ROM_date()
  3570.     
  3571.     Example              #include <ibm.h>
  3572.                          #include <stdio.h>
  3573.     
  3574.                          main()
  3575.                          {
  3576.                               printf("ROM id byte = %X",ROM_id());
  3577.                          }
  3578.     
  3579.     Program output       ROM id byte = FF
  3580.     
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.                                                                    -54-
  3618.  
  3619.     
  3620.     Name                  save_box - save a part of the screen
  3621.     
  3622.     Usage                void save_box(byte top, byte left, byte bottom,
  3623.                                    byte right, byte *buffer);
  3624.     
  3625.     Prototype in         video.h
  3626.     
  3627.     Description          save_box saves part of the current screen
  3628.                          (characters and attributes,) delineated by the box
  3629.                          coordinates, to a block of memory.
  3630.     
  3631.                          buffer MUST be at least big enough to store the
  3632.                          box. save_box will write over memory beginning
  3633.                          with the memory location pointed to by buffer.
  3634.     
  3635.     Return value         nothing.
  3636.     
  3637.     See also             restore_box(), restore_screen(), save_screen()
  3638.     
  3639.     Example              #include <video.h>
  3640.     
  3641.                          main()
  3642.                          {
  3643.                               byte buffer[0x2000];
  3644.     
  3645.                               save_box(0,0,25,39,buffer);  /* save left
  3646.                               half */
  3647.                          }                                 /* of screen    
  3648.                           */
  3649.     
  3650.     
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.                                                                    -55-
  3684.  
  3685.     
  3686.     Name                  save_screen - save screen
  3687.     
  3688.     Usage                void save_screen(byte *buffer);
  3689.     
  3690.     Prototype in         video.h
  3691.     
  3692.     Description          save_screen saves the current screen (characters
  3693.                          and attributes) to a block of memory.
  3694.     
  3695.                          buffer MUST be at least 4K big. save_screen will
  3696.                          write over 4K beginning with the memory location
  3697.                          pointed to by buffer.
  3698.     
  3699.     Return value         nothing.
  3700.     
  3701.     See also             restore_box(), restore_screen(), save_box()
  3702.     
  3703.     Example              #include <video.h>
  3704.     
  3705.                          main()
  3706.                          {
  3707.                               byte buffer[0x4000];
  3708.     
  3709.                               save_screen(buffer);
  3710.                          }
  3711.     
  3712.     
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.                                                                    -56-
  3750.  
  3751.     
  3752.     Name                  scroll_down - scroll window down
  3753.     
  3754.     Usage                void scroll_down(byte top, byte left, byte bottom,
  3755.                                         byte right);
  3756.     
  3757.     Prototype in         video.h
  3758.     
  3759.     Description          scroll box delineated by the coordinates down 1
  3760.                          line. A blank line will be inserted at the top,
  3761.                          and the bottom line will be lost.
  3762.     
  3763.     Return value         nothing.
  3764.     
  3765.     See also             scroll_up()
  3766.     
  3767.     Example              #include <video.h>
  3768.     
  3769.                          main()
  3770.                          {
  3771.                               scroll_down(0,0,4,79);
  3772.                               /* scroll bottom 4 lines */
  3773.                          }
  3774.     
  3775.     
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.                                                                    -57-
  3816.  
  3817.     
  3818.     Name                  scroll_up - scroll window up
  3819.     
  3820.     Usage                void scroll_up(byte top, byte left, byte bottom,
  3821.                                         byte right);
  3822.     
  3823.     Prototype in         video.h
  3824.     
  3825.     Description          scroll box delineated by the coordinates up 1
  3826.                          line. A blank line will be inserted at the bottom,
  3827.                          and the top line will be lost.
  3828.     
  3829.     Return value         nothing.
  3830.     
  3831.     See also             scroll_down()
  3832.     
  3833.     Example              #include <video.h>
  3834.     
  3835.                          main()
  3836.                          {
  3837.                               scroll_up(0,0,4,79); /* scroll top 4 lines */
  3838.                          }
  3839.     
  3840.     
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.  
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.                                                                    -58-
  3882.  
  3883.     
  3884.     Name                  set_color - set the default attribute (color)
  3885.     
  3886.     Usage                void set_color(byte colors);
  3887.     
  3888.     Prototype in         video.h
  3889.     
  3890.     Description          set_color just sets the global variable
  3891.                          char_attribute to colors. I got tired of declaring
  3892.                          char_attribute as extern in every function that
  3893.                          output to the screen, so I made this function.
  3894.     
  3895.     Return value         nothing.
  3896.     
  3897.     See also             putk(), putstr()
  3898.     
  3899.     Example              #include <video.h>
  3900.                          #include <color.h>
  3901.     
  3902.                          main()
  3903.                          {
  3904.                               set_color(RED | B_WHITE | BLINK);
  3905.                               /* red blinking text on white background */
  3906.                               gotoxy(12,40);
  3907.                               putstr((byte *)"Hello");
  3908.                          }
  3909.     
  3910.     
  3911.  
  3912.  
  3913.  
  3914.  
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.                                                                    -59-
  3948.  
  3949.     
  3950.     Name                  set_cursor - sets cursor scan lines
  3951.     
  3952.     Usage                void set_cursor(byte start, byte end);
  3953.     
  3954.     Prototype in         video.h
  3955.     
  3956.     Description          sets the cursor scan lines via INTerrupts.
  3957.     
  3958.     Return value         nothing.
  3959.     
  3960.     See also             cursor_flip(), cursor_off(), cursor_on(),
  3961.                          read_cursor()
  3962.     
  3963.     Example              #include <video.h>
  3964.     
  3965.                          main()
  3966.                          {
  3967.                               set_cursor(0,7);
  3968.                          }
  3969.     
  3970.     
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.                                                                    -60-
  4014.  
  4015.     
  4016.     Name                  set_mode - set the video mode
  4017.     
  4018.     Usage                void set_mode(byte mode);
  4019.     
  4020.     Prototype in         video.h
  4021.     
  4022.     Description          sets the video mode via INT 0x10, Service 0.
  4023.     
  4024.     Return value         nothing.
  4025.     
  4026.     See also             video.h
  4027.                          read_mode()
  4028.     
  4029.     Example              #include <video.h>
  4030.     
  4031.                          main()
  4032.                          {
  4033.                               set_mode(3);       /* text mode */
  4034.                               printf("# columns: %d    Mode: %d   Page:
  4035.                                    %d\n", width, mode, page);
  4036.                          }
  4037.     
  4038.     Program output       # columns: 80    Mode: 3   Page: 1
  4039.     
  4040.     
  4041.  
  4042.  
  4043.  
  4044.  
  4045.  
  4046.  
  4047.  
  4048.  
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.                                                                    -61-
  4080.  
  4081.     
  4082.     Name                  strcomma - convert a string to xx,xxx,xxx format
  4083.     
  4084.     Usage                char *strcomma(char *source); 
  4085.     
  4086.     Prototype in         stringhk.h
  4087.     
  4088.     Description          strcomma converts a string of numbers into the
  4089.                          comma delimited format (xx,xxx,xxx). The number is
  4090.                          terminated by a non-digit (any character other
  4091.                          than 0-9.) A leading sign will be copied before
  4092.                          converting the number. This function is used
  4093.                          internally by strtodol.
  4094.     
  4095.     Return value         returns a pointer to the storage location
  4096.                          containing the comma formatted string, or NULL if
  4097.                          space could not be allocated. The returned string
  4098.                          is NOT the same as the string passed to the
  4099.                          function. This function does NOT write over the
  4100.                          string passed to it.
  4101.     
  4102.     Example              #include <stringhk.h>
  4103.                          #include <stdio.h>           /* for the printf */
  4104.     
  4105.                          main()
  4106.                          {
  4107.                               char sint[15], *comma
  4108.     
  4109.                               strcpy(sint,"12839.44");
  4110.                               comma = strcomma(sint);
  4111.                               printf("%s -> %s\n",sint,comma);
  4112.                          }
  4113.          
  4114.     Program output       12839.44 -> 12,839.44
  4115.     
  4116.     
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.                                                                    -62-
  4146.  
  4147.     
  4148.     Name                  strdel - delete part of a string
  4149.     
  4150.     Usage                char *strdel(char *source, char *old);
  4151.     
  4152.     Prototype in         stringhk.h
  4153.     
  4154.     Description          strdel deletes the first occurence of the string
  4155.                          old from the string source. This function is case
  4156.                          dependent.
  4157.     
  4158.     Return value         returns source
  4159.     
  4160.     Example              #include <stringhk.h>
  4161.                          #include <stdio.h>           /* for the printf */
  4162.     
  4163.                          main()
  4164.                          {
  4165.                               char msg[45], fragment[15];
  4166.     
  4167.                               strcpy(msg,"Did you register yet? Did you?");
  4168.                               strpy(fragment,"you");
  4169.                               printf("  [%s]\n",msg);
  4170.                               printf("- [%s]\n",fragment);
  4171.                               printf("= [%s]\n",msg);
  4172.                          }
  4173.     
  4174.     Program output         [Did you register yet? Did you?]
  4175.                          - [you]
  4176.                          = [Did  register yet? Did you?]
  4177.     
  4178.     
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.                                                                    -63-
  4212.  
  4213.     
  4214.     Name                  strins - insert one string into another
  4215.     
  4216.     Usage                char *strins(char *source, char *new, char *ptr);
  4217.     
  4218.     Prototype in         stringhk.h
  4219.     
  4220.     Description          strins inserts the string new into the string
  4221.                          source at the location ptr in source. Basically,
  4222.                          strins copies source up to, but not including, ptr
  4223.                          into a new location, concatenates the new
  4224.                          (inserted) string, and then concatenates the
  4225.                          remainder of source (the string pointed to by
  4226.                          ptr.)
  4227.     
  4228.     Return value         returns a pointer to the storage location
  4229.                          containing the newly concatenated string, or NULL
  4230.                          if space could not be allocated. The returned
  4231.                          string is NOT the same as the string passed to the
  4232.                          function. This function does NOT write over the
  4233.                          string passed to it.
  4234.     
  4235.     Example              #include <stringhk.h>
  4236.                          #include <stdio.h>           /* for the printf */
  4237.     
  4238.                          main()
  4239.                          {
  4240.                               char old[25], *ptr, *new;
  4241.     
  4242.                               strcpy(old,"ABCDEFG");
  4243.                               ptr = old + 3;            /* *ptr = 'D' */
  4244.                               new = strins(old,"abc",ptr);
  4245.                               printf("%s -> %s\n",old,new);
  4246.                          }
  4247.     
  4248.     Program output       ABCDEDFG -> ABCabcDEFG
  4249.     
  4250.     
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.                                                                    -64-
  4278.  
  4279.     
  4280.     Name                  strrep - replicate a char
  4281.     
  4282.     Usage                char *strrep(char c, int len);
  4283.     
  4284.     Prototype in         stringhk.h
  4285.     
  4286.     Description          strrep copies creates a string len long entirely
  4287.                          of character c.
  4288.     
  4289.     Return value         returns a pointer to the storage location
  4290.                          containing the newly replicated string, or NULL if
  4291.                          space could not be allocated.
  4292.     
  4293.     Example              #include <stringhk.h>
  4294.                          #include <stdio.h>           /* for the printf */
  4295.     
  4296.                          main()
  4297.                          {
  4298.                               char *rep;
  4299.     
  4300.                               printf("%s\n",rep = strrep('k',7));
  4301.                          }
  4302.     
  4303.     Program output       kkkkkkk
  4304.     
  4305.     
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.  
  4314.  
  4315.  
  4316.  
  4317.  
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.                                                                    -65-
  4344.  
  4345.     
  4346.     Name                  strshleft - shift string left
  4347.                           strshright - shift string right
  4348.     
  4349.     Usage                void strshleft(char *source, int count);
  4350.                          void strshright(char *source, int count);
  4351.     
  4352.     Prototype in         stringhk.h
  4353.     
  4354.     Description          these functions shift the characters in the string
  4355.                          source left or right, respectively, count places,
  4356.                          padding with spaces.
  4357.     
  4358.     Return value         returns source.
  4359.     
  4360.     Example              #include <stringhk.h>
  4361.                          #include <stdio.h>           /* for the printf */
  4362.     
  4363.                          main()
  4364.                          {
  4365.                               char msg[25];
  4366.     
  4367.                               strcpy(msg,"Buy a Mac II");
  4368.                               printf("%s\n",msg);
  4369.                               printf("%s\n",strshleft(msg,4));
  4370.                               printf("%s\n",strshright(msg,4));
  4371.                          }
  4372.     
  4373.     Program output       Buy a Mac II
  4374.                          a Mac II
  4375.                              Buy a Ma
  4376.     
  4377.     
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.                                                                    -66-
  4410.  
  4411.     
  4412.     Name                  strtoddate - convert a date string to a
  4413.                          structure
  4414.     
  4415.     Usage                struct ddate *strtoddate(char *source); 
  4416.     
  4417.     Prototype in         datehk.h
  4418.     
  4419.     Description          strtoddate converts a date abbreviation to a
  4420.                          structure of type ddate. The abbreviation can use
  4421.                          dashes or slashes (- or /) to separate the fields
  4422.                          of the date. All fields MUST be of length two
  4423.                          (i.e. 02/07/87 is valid, but 2/7/87 and 02/07/1987
  4424.                          are not valid.)
  4425.     
  4426.     Return value         returns a pointer to the storage location
  4427.                          containing the date structure, or NULL if space
  4428.                          could not be allocated.
  4429.     
  4430.     See also             ddatetolong(), ddatetoshort(), monthexpand(),
  4431.                          strtoddate()
  4432.     
  4433.     Example              #include <datehk.h>
  4434.     
  4435.                          main()
  4436.                          {
  4437.                               struct ddate *today;
  4438.                               char strtoday[9];
  4439.     
  4440.                               strcpy(strtoday,"04/01/67");
  4441.                               if ((today = strtoddate(strtoday) != NULL) {
  4442.                                    printf("today is %d-%d-%d\n",
  4443.                                         today->dmon, today->dday,
  4444.                                         today->dyear);
  4445.                                    printf("or %s\n", strtoday);
  4446.                               }
  4447.                          }
  4448.     
  4449.     Program output       today is 4-1-67
  4450.                          or 04/01/67
  4451.     
  4452.     
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.                                                                    -67-
  4476.  
  4477.     
  4478.     Name                  strtodol - converts a string to dollar format
  4479.     
  4480.     Usage                char *strtodol(char *source); 
  4481.     
  4482.     Prototype in         stringhk.h
  4483.     
  4484.     Description          strtodol converts a string pointed to by source to
  4485.                          dollar format ($-12,839.44). An optional leading
  4486.                          sign is copied. Only the first 2 decimal places
  4487.                          are copied (the string is truncated, not rounded.)
  4488.                          
  4489.     
  4490.     Return value         returns a pointer to the storage location
  4491.                          containing the dollar formatted string, or NULL if
  4492.                          space could not be allocated. The returned string
  4493.                          is NOT the same as the string passed to the
  4494.                          function. This function does NOT write over the
  4495.                          string passed to it.
  4496.     
  4497.     Example              #include <stringhk.h>
  4498.                          #include <stdio.h>           /* for the printf */
  4499.     
  4500.                          main()
  4501.                          {
  4502.                               char sint[15], *dollar
  4503.     
  4504.                               strcpy(sint,"12839.44");
  4505.                               dollar = strtodol(sint);
  4506.                               printf("%s -> %s\n",sint,dollar);
  4507.                               strcpy(sint,"+62939445.1");
  4508.                               dollar = strtodol(sint);
  4509.                               printf("%s -> %s\n",sint,dollar);
  4510.                          }
  4511.          
  4512.     Program output       12839.44 -> $12,839.44
  4513.                          +62939445.1 -> $+62,939,445.10
  4514.     
  4515.     
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.                                                                    -68-
  4542.  
  4543.     
  4544.     Name                  strtotime - convert a string to a time structure
  4545.     
  4546.     Usage                struct time *strtotime(char *source);
  4547.     
  4548.     Prototype in         timehk.h
  4549.     
  4550.     Description          strtotime converts a string to a time structure,
  4551.                          checking for AM/PM or 24-hour format. If seconds
  4552.                          or hundredths of seconds are not in the string,
  4553.                          their values will be set to 0 in the structure.
  4554.     
  4555.     Return value         returns a pointer to the storage location
  4556.                          containing the time string, or NULL if space could
  4557.                          not be allocated.
  4558.     
  4559.     See also             timetostr()
  4560.     
  4561.     Example              #include <timehk.h>
  4562.     
  4563.                          main()
  4564.                          {
  4565.                               struct time *now;
  4566.     
  4567.                               strcpy(strnow,"5:12 PM");
  4568.                               if ((now = strtotime(strnow)) != NULL)
  4569.                                    printf("%d hours, %d min, %d.%d secs\n",
  4570.                                         now->ti_hour, now->ti_min,
  4571.                                         now->ti_sec, now->ti_hund);
  4572.                          }
  4573.     
  4574.     Program output       17 hours, 12 min, 0.0 secs
  4575.     
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.                                                                    -69-
  4608.  
  4609.     
  4610.     Name                  timetostr - convert time structure to a string
  4611.     
  4612.     Usage                char *timetostr(struct time *tsource, boolean
  4613.                                         seconds, boolean hundreds, boolean
  4614.                                         ampm);
  4615.     
  4616.     Prototype in         timehk.h
  4617.     
  4618.     Description          timetostr converts a time structure to a string,
  4619.                          with the following options:
  4620.     
  4621.                               seconds  = put seconds in string
  4622.                               hundreds = put hundreths of seconds in string
  4623.                               ampm     = append AM/PM to string
  4624.     
  4625.                          if ampm is FALSE, 24-hour time will be used.
  4626.     
  4627.                          if hundreds is TRUE, seconds are automatically put
  4628.                          into the string.
  4629.     
  4630.     Return value         returns a pointer to the storage location
  4631.                          containing the time string, or NULL if space could
  4632.                          not be allocated.
  4633.     
  4634.     See also             strtotime()
  4635.     
  4636.     Example              #include <timehk.h>
  4637.     
  4638.                          main()
  4639.                          {
  4640.                               char *strnow;
  4641.                               struct time now;
  4642.     
  4643.                               gettime(&now);
  4644.                               if ((strnow = timetostr(&now, FALSE, TRUE,
  4645.                                                             TRUE)) != NULL)
  4646.                                    printf("The time is %s\n",strnow);
  4647.                          }
  4648.     
  4649.     Program output       The time is 11:23:14.22 PM
  4650.     
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.                                                                    -70-
  4674.  
  4675.     
  4676.     Name                  valid_date - check if a date is valid
  4677.     
  4678.     Usage                boolean valid_date(int month, int day, int
  4679.                          yearnum);
  4680.     
  4681.     Prototype in         datehk.h
  4682.     
  4683.     Description          valid_date checks if the given date is valid.
  4684.     
  4685.     Return value         returns TRUE if the date is valid, FALSE
  4686.                          otherwise.
  4687.     
  4688.     See also             isleapyear()
  4689.     
  4690.     Example              #include <datehk.h>
  4691.     
  4692.                          main()
  4693.                          {
  4694.                               int i, d[3] = { 11, 5, 2 }, m[3] = { 31, 12,
  4695.                               29},
  4696.                                    y[3] = { 70, 1987, 1981 };
  4697.     
  4698.                               for (i=0; i<3; ++) {
  4699.                                    printf("%d/%d/%d  ", m[i], d[i], y[i]);
  4700.                                    if (valid_date(m[i], d[i], y[i])
  4701.                                         printf("valid\n");
  4702.                                    else
  4703.                                         printf("INVALID\n");
  4704.                               }
  4705.                          }
  4706.     
  4707.     Program output       11/31/70  INVALID       /* Nov has 30 days */
  4708.                          5/13/1987  valid
  4709.                          2/29/1981  INVALID      /* 1981 not a leap year */
  4710.     
  4711.  
  4712.  
  4713.  
  4714.  
  4715.  
  4716.  
  4717.  
  4718.  
  4719.  
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.  
  4726.  
  4727.  
  4728.  
  4729.  
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.                                                                    -71-
  4740.  
  4741.     
  4742.     Name                  vert_line - draw a vertical line
  4743.     
  4744.     Usage                void vert_line(byte c, unsigned int len, byte row,
  4745.                                         byte col);
  4746.     
  4747.     Prototype in         video.h
  4748.     
  4749.     Description          draws a vertical line of characters c of length
  4750.                          len beginning at (col,row) via INTerrupts.
  4751.     
  4752.                          vert_line does no error checking on the passed
  4753.                          parameters.
  4754.     
  4755.     Return value         nothing.
  4756.     
  4757.     See also             box(), horiz_line(), restore_box(),
  4758.                          restore_screen(), save_box(), save_screen()
  4759.     
  4760.     Example              #include <video.h>
  4761.     
  4762.                          main()
  4763.                          {
  4764.                               vert_line('*',7,4,4);   /* draw 7 *'s at
  4765.                               (4,4) */
  4766.                          }
  4767.     
  4768.     
  4769.  
  4770.  
  4771.  
  4772.  
  4773.  
  4774.  
  4775.  
  4776.  
  4777.  
  4778.  
  4779.  
  4780.  
  4781.  
  4782.  
  4783.  
  4784.  
  4785.  
  4786.  
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.  
  4793.  
  4794.  
  4795.  
  4796.  
  4797.  
  4798.  
  4799.  
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.                                                                    -72-
  4806.  
  4807.     
  4808.     Name                  wherex - X-coordinate of cursor 
  4809.     
  4810.     Usage                byte wherex(void);
  4811.     
  4812.     Prototype in         video.h
  4813.     
  4814.     Description          returns the X-coordinate (column) of the cursor's
  4815.                          current location via INT 0x10, Service 3.
  4816.     
  4817.     Return value         returns the X-coordinate of the cursor's current
  4818.                          location.
  4819.     
  4820.     See also             gotoxy(), read_cursor(), wherey()
  4821.     
  4822.     Example              #include <video.h>
  4823.     
  4824.                          main()
  4825.                          {
  4826.                               printf("Cursor's column = %d\n",wherex());
  4827.                          }
  4828.     
  4829.     Program output       Cursor's column = 12
  4830.     
  4831.  
  4832.  
  4833.  
  4834.  
  4835.  
  4836.  
  4837.  
  4838.  
  4839.  
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845.  
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.  
  4852.  
  4853.  
  4854.  
  4855.  
  4856.  
  4857.  
  4858.  
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.  
  4865.  
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.                                                                    -73-
  4872.  
  4873.     
  4874.     Name                  wherey - y-coordinate of cursor 
  4875.     
  4876.     Usage                byte wherey(void);
  4877.     
  4878.     Prototype in         video.h
  4879.     
  4880.     Description          returns the Y-coordinate (row) of the cursor's
  4881.                          current location via INT 0x10, Service 3.
  4882.     
  4883.     Return value         returns the Y-coordinate of the cursor's current
  4884.                          location.
  4885.     
  4886.     See also             gotoxy(), read_cursor(), wherex()
  4887.     
  4888.     Example              #include <video.h>
  4889.     
  4890.                          main()
  4891.                          {
  4892.                               printf("Cursor's row = %d\n",wherey());
  4893.                          }
  4894.     
  4895.     Program output       Cursor's row = 4
  4896.     
  4897.  
  4898.  
  4899.  
  4900.  
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.                                                                    -74-
  4938.  
  4939.                                     #DEFINES
  4940.     
  4941.           Most of these #defines are self-explanatory. All can be found in
  4942.           the appropriate header files:
  4943.     
  4944.      Datehk.h
  4945.     --------
  4946.     
  4947.           Date definitions:
  4948.     
  4949.                typedef enum { Sun, Mon, Tues, Wed, Thrus, Fri, Sat } days;
  4950.                typedef enum { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep,
  4951.                               Oct, Nov, Dec } months;
  4952.     
  4953.           My date structure:
  4954.     
  4955.                typedef struct ddate {
  4956.                               int dyear;     /* Year - 1900 */
  4957.                               int dday;      /* Day of month (1-31) */
  4958.                               months dmon;   /* Month (Jan = 0) */
  4959.                          };
  4960.     
  4961.          Note: the year is stored as Year - 1900. For example, if you
  4962.                wanted to store 1987 in the variable d (of type struct
  4963.                ddate), you would:       d.dyear = 87;
  4964.                Also note that the months start with zero for January.
  4965.     
  4966.           Date constants:
  4967.     
  4968.                #define DATENULL      "  -  -  "   /* empty date string */
  4969.                #define DATECHAR      '-'          /* date delimiter char */
  4970.                #define DATECHARSTR   "-"          /* date delim. string */
  4971.                #define BASE_LEAP_YEAR  1980       /* base year for leap
  4972.                                                        year calculations */
  4973.     
  4974.     
  4975.      Howard.h
  4976.     --------
  4977.     
  4978.           Boolean constants:
  4979.     
  4980.                #define TRUE  1
  4981.                #define FALSE 0
  4982.     
  4983.     
  4984.      Ibm.h
  4985.     -----
  4986.     
  4987.           Machine id byte:
  4988.     
  4989.                #define PC            0xFF
  4990.                #define XT            0xFE
  4991.                #define Portable_PC   0xFE
  4992.                #define PCjr          0xFD
  4993.                #define AT            0xFC
  4994.                #define Compaq        0x2D
  4995.                #define Compaq_Plus   0x9A
  4996.     
  4997.     
  4998.     
  4999.  
  5000.  
  5001.  
  5002.  
  5003.                                                                    -75-
  5004.  
  5005.      Math.h
  5006.     ------
  5007.     
  5008.          Math constants:
  5009.     
  5010.                #define SQRT2   1.41421356237309504880
  5011.                #define PI  3.141592653589793238462643
  5012.                #define E   2.7182818284590452353602874
  5013.     
  5014.          Math functions:
  5015.     
  5016.                #define sqr(x)      ((x) * (x))
  5017.                #define sgn(x)      ((x) < 0 ? -1 : 1)
  5018.                #define sign(x)     ((x) < 0 ? -1 : 1)
  5019.                #define swap(x,y)   x^=y, y^=x, x^=y
  5020.                #define max(x,y)    ((x) >= (y) ? (x) : (y))
  5021.                #define min(x,y)    ((x) <= (y) ? (x) : (y))
  5022.     
  5023.     
  5024.      Video.h
  5025.     -------
  5026.     
  5027.           Low memory address values:
  5028.     
  5029.                #define VIDEO     0x10
  5030.                     /* VIDEO INTerrupt service */
  5031.                #define MODE      *((byte far *) 0x449lu)
  5032.                     /* current video mode */
  5033.                #define PAGE      *((byte far *) 0x462lu)
  5034.                     /* current display page */
  5035.                #define PAGELEN   *((unsigned int far *) 0x44Clu)
  5036.                     /* current page length (regen buffer) */
  5037.                #define VIDOFFSET *((unsigned int far *) 0x44Elu)
  5038.                     /* offset from start of video */
  5039.                #define ROWCOUNT  *((byte far *) 0x484lu)
  5040.                     /* # rows minus 1 on display (EGA,PGA) */
  5041.                #define CHARHEIGHT *((unsigned int far *) 0x485lu)
  5042.                     /* character height: # bytes/char, # scan lines/char
  5043.                          (EGA,PGA) */
  5044.                #define CURSOR_UNDERBAR   (MODE==7)?0x0B0C:0x0607
  5045.                     /* cursor type: underbar (default) */
  5046.                #define CURSOR_HALFBLOCK  (MODE==7)?0x070C:0x0407
  5047.                     /* cursor type: half-block */
  5048.     
  5049.     
  5050.     
  5051.                                  VARIABLE TYPES
  5052.     
  5053.           The following variable types have been defined:
  5054.     
  5055.                boolean = char           Howard.h
  5056.                byte = unsigned char     defined in TC.EXE. See Features.
  5057.                struct ddate             Datehk.h
  5058.     
  5059.     
  5060.     
  5061.     
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.                                                                    -76-
  5070.  
  5071.                                 GLOBAL VARIABLES
  5072.     
  5073.           These variables are defined for one reason or another and used
  5074.           internally. None of these variables have to be initialized (see
  5075.           insertmode.) They are mainly used to return extra values found in
  5076.           certain functions or needed globally by other functions.
  5077.     
  5078.     
  5079.            Keyboard variables:
  5080.     
  5081.                boolean key_extended;    /* TRUE if special key pressed,
  5082.                                            i.e. Alt-X, etc. */
  5083.                int key_status;          /* shift key status byte */
  5084.     
  5085.          Note: these variables are set by inkey() and getk(), and are
  5086.                checked by many other keyboard routines.
  5087.     
  5088.                boolean insertmode;      /* insert or overwrite mode? */
  5089.     
  5090.          Note: This variable is used internally by getstr() and getget().
  5091.                These functions do NOT initialize this variable. You MUST
  5092.                set insertmode to TRUE or FALSE before calling either
  5093.                function or unpredictable results may occur. Upon completion
  5094.                of this function, testing this variable will determine the
  5095.                input mode last used. Future versions will default
  5096.                insertmode to some value if it has not been set.
  5097.     
  5098.            Video variables:
  5099.     
  5100.                byte char_attribute;     /* char attribute for output */
  5101.     
  5102.          Note: This variable is used by many output functions to set the
  5103.                attribute byte. For functions such as putstr() you can
  5104.                either call set_color() with the attribute desired or
  5105.                declare char_attribute as an extern and then set it
  5106.                yourself.
  5107.     
  5108.     
  5109.     
  5110.                                 FUTURE REVISIONS
  5111.     
  5112.           I have tried to put as many of my functions into this release of
  5113.           TCHK as I can. In future releases, look for the following
  5114.           features:
  5115.     
  5116.                - direct screen accesses coded in assembler
  5117.                - some more video routines
  5118.                - enhancement of the get and put routines to support all
  5119.                  features found in the @...SAY...GET commands of dBase III+
  5120.                - enhancement of the put routines to support the 'backslash'
  5121.                  control characters like printf does (\n, \t, etc.)
  5122.                - more date functions (Julian, Gregorian, and more)
  5123.                - some sound functions
  5124.                - more window interfaces (popups, Macintosh pulldown menus)
  5125.                - mouse functions
  5126.                - more EMS functions
  5127.                - more hardware id functions (cpu/numeric coprocessor type)
  5128.                - several math functions (integrals, derivatives, ...)
  5129.     
  5130.     
  5131.     
  5132.  
  5133.  
  5134.  
  5135.                                                                    -77-
  5136.  
  5137.           If there are some features you would like to see implemented, or
  5138.           you have any suggestions, comments or questions, please don't
  5139.           hesitate to contact me. I can be reached at:
  5140.     
  5141.                Howard Kapustein
  5142.                1695 Barbara Lane
  5143.                East Meadow, NY 11554
  5144.                Phone: (516) 481-9612
  5145.     
  5146.           or at the following bulletin boards:
  5147.     
  5148.                The Boss dBBS       (201) 568-7293
  5149.                The Tool Shop       (602) 279-2673
  5150.     
  5151.  
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.                                                                     -78-
  5202.  
  5203.                                      Index
  5204.     
  5205.     
  5206.     A                                        I
  5207.     Atrim           7                        Inkey           28, 29, 32, 35, 76
  5208.                                              Intlen          36
  5209.     B                                        IsCGA           37
  5210.     Box             6, 8, 9, 34, 50,         IsEGA           37
  5211.                     51, 54, 55, 56,          IsEMSavail      38
  5212.                     57, 71                   IsHerc          37
  5213.                                              Isleapyear      39, 70
  5214.     C                                        IsMDA           37
  5215.     Clear           9, 10, 11
  5216.     Clear_typeahead   10                     L
  5217.     Cls             9, 11                    Leftstr         40
  5218.     Cursor_flip     12, 13, 14, 48,          Lotus_setup     41, 43
  5219.                     59                       Ltrim           7
  5220.     Cursor_off      12, 13, 14, 48,
  5221.                     59                       M
  5222.     Cursor_on       12, 13, 14, 48,          Menu_lotus      41, 42
  5223.                     59                       Midstr          40
  5224.                                              Monthexpand     17, 18, 19, 44, 66
  5225.     D
  5226.     Dayofyear       15, 16, 21               P
  5227.     Daysleft        15, 16, 21               Putk            22, 23, 24, 27, 30,
  5228.     Ddatetolong     17, 18, 19, 44,                          31, 45, 46, 47, 58
  5229.                     66                       Putsay          45, 46, 47
  5230.     Ddatetoshort    17, 18, 19, 44,          Putstr          29, 32, 42, 45, 46,
  5231.                     66                                       47, 58, 76
  5232.     Ddatetostr      17, 18, 19, 44                                        
  5233.     Delay           20                       R
  5234.     Diffddate       15, 16, 21               Read_cursor     12, 13, 14, 33, 48,
  5235.                                                              59, 72, 73
  5236.     G                                        Read_mode       49, 60
  5237.     Getc_match      22, 28, 29, 32,          Restore_box     8, 34, 50, 51, 54,
  5238.                     35                                       55, 71
  5239.     Getddate        23                       Restore_screen  8, 34, 50, 51, 54,
  5240.     Getdouble       24, 27, 30                               55, 71
  5241.     Getfname        25                       Ri